Fixed typing
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 88f7b39..91e074d 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -34,7 +34,7 @@
let deleteDays;
if (!interaction.isButton()) {
member = interaction.options.getMember("user") as GuildMember;
- deleteDays = (interaction.options.get("delete")?.value as number | null) ?? 0
+ deleteDays = (interaction.options.get("delete")?.value as number | null) ?? 0;
} else {
deleteDays = 0;
}
@@ -115,12 +115,7 @@
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.ban.text)
- .setURL(
- config.moderation.ban.link.replaceAll(
- "{id}",
- member.id
- )
- )
+ .setURL(config.moderation.ban.link.replaceAll("{id}", member.id))
)
);
}
@@ -204,7 +199,7 @@
apply = target!;
} else {
apply = interaction.options.getMember("user") as GuildMember;
- };
+ }
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
const applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 4d325a2..4ef78c8 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -103,12 +103,7 @@
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.kick.text)
- .setURL(
- config.moderation.kick.link.replaceAll(
- "{id}",
- member.id
- )
- )
+ .setURL(config.moderation.kick.link.replaceAll("{id}", member.id))
)
);
}
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 51ffc4d..2266a1a 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,5 +1,12 @@
import { LinkWarningFooter, LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle, ButtonInteraction } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ButtonInteraction
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -49,7 +56,10 @@
.setRequired(false)
);
-const callback = async (interaction: CommandInteraction | ButtonInteraction, member?: GuildMember): Promise<unknown> => {
+const callback = async (
+ interaction: CommandInteraction | ButtonInteraction,
+ member?: GuildMember
+): Promise<unknown> => {
if (!interaction.guild) return;
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
let time: { days: number; hours: number; minutes: number; seconds: number } | null = null;
@@ -62,7 +72,7 @@
seconds: (interaction.options.get("seconds")?.value as number | null) ?? 0
};
} else {
- time = {days: 0, hours: 0, minutes: 0, seconds: 0};
+ time = { days: 0, hours: 0, minutes: 0, seconds: 0 };
}
if (!member) return;
const config = await client.database.guilds.read(interaction.guild.id);
@@ -203,8 +213,7 @@
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () =>
- await create(interaction.guild!, member!.user, interaction.user, reason),
+ async () => await create(interaction.guild!, member!.user, interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
null,
"CONTROL.TICKET",
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 743579b..cfdcf47 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,5 +1,16 @@
import { LinkWarningFooter } from "./../../utils/defaults.js";
-import { ActionRowBuilder, ButtonBuilder, CommandInteraction, GuildMember, ButtonStyle, Message, ButtonInteraction, ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ CommandInteraction,
+ GuildMember,
+ ButtonStyle,
+ Message,
+ ButtonInteraction,
+ ModalBuilder,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -17,7 +28,10 @@
option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
);
-const callback = async (interaction: CommandInteraction | ButtonInteraction, member?: GuildMember): Promise<unknown> => {
+const callback = async (
+ interaction: CommandInteraction | ButtonInteraction,
+ member?: GuildMember
+): Promise<unknown> => {
const { log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
let newNickname;
if (!interaction.isButton()) {
@@ -39,28 +53,15 @@
.setDescription(
keyValueList({
user: renderUser(member.user),
- "new nickname": `${
- newNickname
- ? newNickname
- : "*No nickname*"
- }`
- }) +
- `Are you sure you want to ${
- newNickname ? "change" : "clear"
- } <@!${member.id}>'s nickname?`
+ "new nickname": `${newNickname ? newNickname : "*No nickname*"}`
+ }) + `Are you sure you want to ${newNickname ? "change" : "clear"} <@!${member.id}>'s nickname?`
)
.setColor("Danger")
.addCustomBoolean(
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild!.id)),
- async () =>
- await create(
- interaction.guild!,
- member!.user,
- interaction.user,
- "Nickname changed"
- ),
+ async () => await create(interaction.guild!, member!.user, interaction.user, "Nickname changed"),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -81,18 +82,16 @@
"ICONS.EDIT",
"modal",
newNickname ?? "",
- new ModalBuilder()
- .setTitle("Editing nickname")
- .addComponents(
- new ActionRowBuilder<TextInputBuilder>().addComponents(
- new TextInputBuilder()
- .setCustomId("default")
- .setLabel("Nickname")
- .setMaxLength(32)
- .setRequired(false)
- .setStyle(TextInputStyle.Short)
- .setValue(newNickname ? newNickname : " ")
- )
+ new ModalBuilder().setTitle("Editing nickname").addComponents(
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("default")
+ .setLabel("Nickname")
+ .setMaxLength(32)
+ .setRequired(false)
+ .setStyle(TextInputStyle.Short)
+ .setValue(newNickname ? newNickname : " ")
+ )
)
)
.setFailedMessage("No changes were made", "Success", "PUNISH.NICKNAME.GREEN")
@@ -104,7 +103,7 @@
notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
- if (confirmation.modals) newNickname = confirmation.modals![0]!.value
+ if (confirmation.modals) newNickname = confirmation.modals![0]!.value;
} while (!timedOut && !success);
if (timedOut || !success) return;
let dmSent = false;
@@ -121,12 +120,8 @@
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(
- `Your nickname was ${
- newNickname ? "changed" : "cleared"
- } in ${interaction.guild!.name}.` +
- (newNickname
- ? `\nIt is now: ${newNickname}`
- : "") +
+ `Your nickname was ${newNickname ? "changed" : "cleared"} in ${interaction.guild!.name}.` +
+ (newNickname ? `\nIt is now: ${newNickname}` : "") +
"\n\n" +
(createAppealTicket
? `You can appeal this in the ticket created in <#${
@@ -145,12 +140,7 @@
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.nick.text)
- .setURL(
- config.moderation.nick.link.replaceAll(
- "{id}",
- member.id
- )
- )
+ .setURL(config.moderation.nick.link.replaceAll("{id}", member.id))
)
);
}
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index ff69079..dadab04 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -101,8 +101,7 @@
let component;
try {
component = m.awaitMessageComponent({
- filter: (i) =>
- i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id,
+ filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id,
time: 300000
});
} catch (e) {
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 8408303..232219b 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,4 +1,11 @@
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle, ButtonInteraction } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ButtonInteraction
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -14,7 +21,10 @@
.setDescription("Warns a user")
.addUserOption((option) => option.setName("user").setDescription("The user to warn").setRequired(true));
-const callback = async (interaction: CommandInteraction | ButtonInteraction, member?: GuildMember): Promise<unknown> => {
+const callback = async (
+ interaction: CommandInteraction | ButtonInteraction,
+ member?: GuildMember
+): Promise<unknown> => {
if (!interaction.guild) return;
const { log, NucleusColors, renderUser, entry } = client.logger;
if (!interaction.isButton()) member = interaction.options.getMember("user") as GuildMember;
@@ -41,8 +51,7 @@
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () =>
- await create(interaction.guild!, member!.user, interaction.user, reason),
+ async () => await create(interaction.guild!, member!.user, interaction.user, reason),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -110,12 +119,7 @@
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.warn.text)
- .setURL(
- config.moderation.warn.link.replaceAll(
- "{id}",
- member.id
- )
- )
+ .setURL(config.moderation.warn.link.replaceAll("{id}", member.id))
)
);
}
@@ -135,10 +139,7 @@
timestamp: Date.now()
},
list: {
- user: entry(
- member.user.id,
- renderUser(member.user)
- ),
+ user: entry(member.user.id, renderUser(member.user)),
warnedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
reason: reason ? reason : "*No reason provided*"
},
@@ -151,13 +152,7 @@
guild: interaction.guild.id
}
};
- await client.database.history.create(
- "warn",
- interaction.guild.id,
- member.user,
- interaction.user,
- reason
- );
+ await client.database.history.create("warn", interaction.guild.id, member.user, interaction.user, reason);
log(data);
const failed = !dmSent && notify;
if (!failed) {
@@ -179,9 +174,7 @@
components: []
});
} else {
- const canSeeChannel = member
- .permissionsIn(interaction.channel as Discord.TextChannel)
- .has("ViewChannel");
+ const canSeeChannel = member.permissionsIn(interaction.channel as Discord.TextChannel).has("ViewChannel");
const m = (await interaction.editReply({
embeds: [
new EmojiEmbed()
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index 1eceae2..294ee27 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -1,4 +1,18 @@
-import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelType, CommandInteraction, ComponentType, Guild, ModalBuilder, ModalSubmitInteraction, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ AttachmentBuilder,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ ChannelType,
+ CommandInteraction,
+ ComponentType,
+ Guild,
+ ModalBuilder,
+ ModalSubmitInteraction,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -8,7 +22,7 @@
builder.setName("stats").setDescription("Gets the bot's stats");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- const description = `**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``
+ const description = `**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``;
const m = await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -28,30 +42,39 @@
.setDescription(description)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary),
- new ButtonBuilder().setCustomId("mod:nickname:599498449733550102").setLabel("Testing").setStyle(ButtonStyle.Primary)
- )]
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId("mod:nickname:599498449733550102")
+ .setLabel("Testing")
+ .setStyle(ButtonStyle.Primary)
+ )
+ ]
});
const modal = new ModalBuilder()
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setStyle(TextInputStyle.Short)
- .setLabel("Guild ID")
- .setCustomId("guildID")
- .setPlaceholder("Guild ID")
- .setMinLength(16)
- .setMaxLength(25)
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setStyle(TextInputStyle.Short)
+ .setLabel("Guild ID")
+ .setCustomId("guildID")
+ .setPlaceholder("Guild ID")
+ .setMinLength(16)
+ .setMaxLength(25)
+ )
)
.setTitle("Admin Panel")
- .setCustomId("adminPanel")
+ .setCustomId("adminPanel");
let i1: ButtonInteraction;
- const channel = await client.channels.fetch(interaction.channelId)
- if(!channel || [ChannelType.GuildCategory, ChannelType.GroupDM, ChannelType.GuildStageVoice].includes(channel.type)) return;
+ const channel = await client.channels.fetch(interaction.channelId);
+ if (
+ !channel ||
+ [ChannelType.GuildCategory, ChannelType.GroupDM, ChannelType.GuildStageVoice].includes(channel.type)
+ )
+ return;
// console.log(interaction)
if (!("awaitMessageComponent" in channel)) return;
try {
@@ -59,27 +82,28 @@
filter: (i) => i.customId === "admin" && i.user.id === interaction.user.id,
time: 300000
});
- } catch (e) { console.log(e); return }
- await i1.showModal(modal)
+ } catch (e) {
+ console.log(e);
+ return;
+ }
+ await i1.showModal(modal);
let out: ModalSubmitInteraction;
try {
out = await i1.awaitModalSubmit({
filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id,
time: 300000
- })
- } catch { return }
+ });
+ } catch {
+ return;
+ }
out.deferUpdate();
const GuildID = out.fields.getTextInputValue("guildID");
if (!client.guilds.cache.has(GuildID)) {
await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Admin")
- .setDescription("Not in server")
- .setStatus("Danger")
- ], components: []
+ embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")],
+ components: []
});
- };
+ }
await interaction.editReply({
embeds: [],
@@ -91,24 +115,23 @@
new ButtonBuilder().setCustomId("purge").setLabel("Delete data").setStyle(ButtonStyle.Danger),
new ButtonBuilder().setCustomId("cache").setLabel("Reset cache").setStyle(ButtonStyle.Success)
)
- ]});
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent<ComponentType.Button>({
filter: (i) => i.user.id === interaction.user.id,
time: 300000
- })
- } catch { return }
+ });
+ } catch {
+ return;
+ }
i.deferUpdate();
- const guild = await client.guilds.fetch(GuildID) as Guild | null;
+ const guild = (await client.guilds.fetch(GuildID)) as Guild | null;
if (!guild) {
await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Admin")
- .setDescription("Not in server")
- .setStatus("Danger")
- ], components: []
+ embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")],
+ components: []
});
return;
}
@@ -119,17 +142,17 @@
.setTitle("Stats")
.setDescription(
`**Name:** ${guild.name}\n` +
- `**ID:** \`${guild.id}\`\n` +
- `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` +
- `**Member Count:** ${guild.memberCount}\n` +
- `**Created:** <t:${guild.createdTimestamp}:F>\n` +
- `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` +
- `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n`
+ `**ID:** \`${guild.id}\`\n` +
+ `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` +
+ `**Member Count:** ${guild.memberCount}\n` +
+ `**Created:** <t:${guild.createdTimestamp}:F>\n` +
+ `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` +
+ `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n`
)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
]
- })
+ });
} else if (i.customId === "leave") {
await guild.leave();
await interaction.editReply({
@@ -139,8 +162,9 @@
.setDescription(`Left ${guild.name}`)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ], components: []
- })
+ ],
+ components: []
+ });
} else if (i.customId === "data") {
// Get all the data and convert to a string
const data = await client.database.guilds.read(guild.id);
@@ -150,9 +174,10 @@
await interaction.editReply({
embeds: [
new EmojiEmbed().setTitle("Data").setDescription(`Data for ${guild.name}`).setStatus("Success")
- ], components: [],
+ ],
+ components: [],
files: [attachment]
- })
+ });
} else if (i.customId === "purge") {
await client.database.guilds.delete(GuildID);
await client.database.history.delete(GuildID);
@@ -165,8 +190,9 @@
.setDescription(`Deleted data for ${guild.name}`)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ], components: []
- })
+ ],
+ components: []
+ });
} else if (i.customId === "cache") {
await client.memory.forceUpdate(guild.id);
await interaction.editReply({
@@ -176,8 +202,9 @@
.setDescription(`Reset cache for ${guild.name}`)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ], components: []
- })
+ ],
+ components: []
+ });
}
}
};
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 0c174f5..e683e4f 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -176,7 +176,7 @@
m: Message,
data?: ObjectSchema
): Promise<ObjectSchema | null> => {
- if (!data) data = _.cloneDeep(defaultRoleMenuData)
+ if (!data) data = _.cloneDeep(defaultRoleMenuData);
const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("back")
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 41a22c1..34a52b8 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -2,6 +2,7 @@
import type { NucleusClient } from "../utils/client.js";
import type { LoggerOptions } from "../utils/log.js";
import { generalException } from "../utils/createTemporaryStorage.js";
+import { doMemberChecks } from "../reflex/scanners.js";
export const event = "guildMemberUpdate";
@@ -92,6 +93,7 @@
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
if (before.nickname !== after.nickname) {
+ doMemberChecks(after, after.guild);
await client.database.history.create(
"nickname",
after.guild.id,
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 4a8d941..3b0cd62 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -19,10 +19,7 @@
async function errorMessage(interaction: ButtonInteraction, message: string) {
await interaction.reply({
- embeds: [new EmojiEmbed()
- .setDescription(message)
- .setStatus("Danger")
- ],
+ embeds: [new EmojiEmbed().setDescription(message).setStatus("Danger")],
ephemeral: true,
components: []
});
@@ -60,23 +57,27 @@
const member = await interaction.guild?.members.fetch(memberId!);
switch (action) {
case "kick": {
- const check = await kickCheck(interaction, false, member)
+ const check = await kickCheck(interaction, false, member);
if (check !== true) return await errorMessage(interaction, check!);
return await kickCallback(interaction, member);
- } case "ban": {
- const check = await banCheck(interaction, false, member)
+ }
+ case "ban": {
+ const check = await banCheck(interaction, false, member);
if (check !== true) return await errorMessage(interaction, check!);
return await banCallback(interaction, member);
- } case "mute": {
- const check = await muteCheck(interaction, false, member)
+ }
+ case "mute": {
+ const check = await muteCheck(interaction, false, member);
if (check !== true) return await errorMessage(interaction, check!);
return await muteCallback(interaction, member);
- } case "nickname": {
- const check = await nicknameCheck(interaction, false, member)
+ }
+ case "nickname": {
+ const check = await nicknameCheck(interaction, false, member);
if (check !== true) return await errorMessage(interaction, check || "Something went wrong");
return await nicknameCallback(interaction, member);
- } case "warn": {
- const check = await warnCheck(interaction, false, member)
+ }
+ case "warn": {
+ const check = await warnCheck(interaction, false, member);
if (check !== true) return await errorMessage(interaction, check!);
return await warnCallback(interaction, member);
}
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 191ba6b..66abe28 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -9,7 +9,7 @@
export async function callback(client: NucleusClient, member: GuildMember) {
welcome(member);
statsChannelAdd(member.user, member.guild);
- doMemberChecks(member, member.guild)
+ doMemberChecks(member, member.guild);
const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger;
if (!(await isLogging(member.guild.id, "guildMemberUpdate"))) return;
await client.database.history.create("join", member.guild.id, member.user, null, null);
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index f00e82c..192be25 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -5,9 +5,9 @@
import type Discord from "discord.js";
import client from "../utils/client.js";
import { createHash } from "crypto";
-import * as nsfwjs from 'nsfwjs';
-import * as clamscan from 'clamscan'
-import * as tf from "@tensorflow/tfjs-node";
+// import * as nsfwjs from "nsfwjs";
+// import * as clamscan from "clamscan";
+// import * as tf from "@tensorflow/tfjs-node";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
@@ -21,10 +21,10 @@
errored?: boolean;
}
-const model = await nsfwjs.load();
+// const model = await nsfwjs.load();
export async function testNSFW(link: string): Promise<NSFWSchema> {
- const [fileName, hash] = await saveAttachment(link);
+ const [_fileName, hash] = await saveAttachment(link);
const alreadyHaveCheck = await client.database.scanCache.read(hash);
if (alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
@@ -167,7 +167,12 @@
}
}
-export function TestString(string: string, soft: string[], strict: string[], enabled?: boolean): {word: string, type: string} | null {
+export function TestString(
+ string: string,
+ soft: string[],
+ strict: string[],
+ enabled?: boolean
+): { word: string; type: string } | null {
if (!enabled) return null;
for (const word of strict) {
if (string.toLowerCase().includes(word)) {
@@ -197,34 +202,56 @@
if (member.user.bot) return;
const guildData = await client.database.guilds.read(guild.id);
if (!guildData.logging.staff.channel) return;
- const [ loose, strict ] = [guildData.filters.wordFilter.words.loose, guildData.filters.wordFilter.words.strict];
+ const [loose, strict] = [guildData.filters.wordFilter.words.loose, guildData.filters.wordFilter.words.strict];
// Does the username contain filtered words
const usernameCheck = TestString(member.user.username, loose, strict, guildData.filters.wordFilter.enabled);
// Does the nickname contain filtered words
const nicknameCheck = TestString(member.nickname ?? "", loose, strict, guildData.filters.wordFilter.enabled);
// Does the profile picture contain filtered words
- const avatarTextCheck = TestString(await TestImage(member.user.displayAvatarURL({ forceStatic: true })) ?? "", loose, strict, guildData.filters.wordFilter.enabled);
+ const avatarTextCheck = TestString(
+ (await TestImage(member.user.displayAvatarURL({ forceStatic: true }))) ?? "",
+ loose,
+ strict,
+ guildData.filters.wordFilter.enabled
+ );
// Is the profile picture NSFW
- const avatarCheck = guildData.filters.images.NSFW && await NSFWCheck(member.user.displayAvatarURL({ forceStatic: true }));
+ const avatarCheck =
+ guildData.filters.images.NSFW && (await NSFWCheck(member.user.displayAvatarURL({ forceStatic: true })));
// Does the username contain an invite
- const inviteCheck = guildData.filters.invite.enabled && member.user.username.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
+ const inviteCheck =
+ guildData.filters.invite.enabled && member.user.username.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
// Does the nickname contain an invite
- const nicknameInviteCheck = guildData.filters.invite.enabled && member.nickname?.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
+ const nicknameInviteCheck =
+ guildData.filters.invite.enabled && member.nickname?.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
- if (usernameCheck !== null || nicknameCheck !== null || avatarCheck || inviteCheck || nicknameInviteCheck || avatarTextCheck !== null) {
+ if (
+ usernameCheck !== null ||
+ nicknameCheck !== null ||
+ avatarCheck ||
+ inviteCheck ||
+ nicknameInviteCheck ||
+ avatarTextCheck !== null
+ ) {
const infractions = [];
if (usernameCheck !== null) {
infractions.push(`Username contains a ${usernameCheck.type}ly filtered word (${usernameCheck.word})`);
- } if (nicknameCheck !== null) {
+ }
+ if (nicknameCheck !== null) {
infractions.push(`Nickname contains a ${nicknameCheck.type}ly filtered word (${nicknameCheck.word})`);
- } if (avatarCheck) {
+ }
+ if (avatarCheck) {
infractions.push("Profile picture is NSFW");
- } if (inviteCheck) {
+ }
+ if (inviteCheck) {
infractions.push("Username contains an invite");
- } if (nicknameInviteCheck) {
+ }
+ if (nicknameInviteCheck) {
infractions.push("Nickname contains an invite");
- } if (avatarTextCheck !== null) {
- infractions.push(`Profile picture contains a ${avatarTextCheck.type}ly filtered word: ${avatarTextCheck.word}`);
+ }
+ if (avatarTextCheck !== null) {
+ infractions.push(
+ `Profile picture contains a ${avatarTextCheck.type}ly filtered word: ${avatarTextCheck.word}`
+ );
}
if (infractions.length === 0) return;
// This is bad - Warn in the staff notifications channel
@@ -234,34 +261,43 @@
.setTitle("Member Flagged")
.setEmoji("ICONS.FLAGS.RED")
.setStatus("Danger")
- .setDescription(`**Member:** ${member.user.username} (<@${member.user.id}>)\n\n` +
- infractions.map((element) => `${filter} ${element}`).join("\n")
- )
+ .setDescription(
+ `**Member:** ${member.user.username} (<@${member.user.id}>)\n\n` +
+ infractions.map((element) => `${filter} ${element}`).join("\n")
+ );
await channel.send({
embeds: [embed],
- components: [new ActionRowBuilder<ButtonBuilder>().addComponents(...[
- new ButtonBuilder()
- .setCustomId(`mod:warn:${member.user.id}`)
- .setLabel("Warn")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId(`mod:mute:${member.user.id}`)
- .setLabel("Mute")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId(`mod:kick:${member.user.id}`)
- .setLabel("Kick")
- .setStyle(ButtonStyle.Danger),
- new ButtonBuilder()
- .setCustomId(`mod:ban:${member.user.id}`)
- .setLabel("Ban")
- .setStyle(ButtonStyle.Danger),
- ].concat((usernameCheck !== null || nicknameCheck !== null || avatarTextCheck !== null) ? [
- new ButtonBuilder()
- .setCustomId(`mod:nickname:${member.user.id}`)
- .setLabel("Change Name")
- .setStyle(ButtonStyle.Primary)
- ] : []))]
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ ...[
+ new ButtonBuilder()
+ .setCustomId(`mod:warn:${member.user.id}`)
+ .setLabel("Warn")
+ .setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId(`mod:mute:${member.user.id}`)
+ .setLabel("Mute")
+ .setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId(`mod:kick:${member.user.id}`)
+ .setLabel("Kick")
+ .setStyle(ButtonStyle.Danger),
+ new ButtonBuilder()
+ .setCustomId(`mod:ban:${member.user.id}`)
+ .setLabel("Ban")
+ .setStyle(ButtonStyle.Danger)
+ ].concat(
+ usernameCheck !== null || nicknameCheck !== null || avatarTextCheck !== null
+ ? [
+ new ButtonBuilder()
+ .setCustomId(`mod:nickname:${member.user.id}`)
+ .setLabel("Change Name")
+ .setStyle(ButtonStyle.Primary)
+ ]
+ : []
+ )
+ )
+ ]
});
}
-}
\ No newline at end of file
+}
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 5bfbfdb..7b3bd31 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -37,7 +37,13 @@
inverted = false;
reason: string | null = null;
- modals: {buttonText: string, emoji: string, customId: string, modal: Discord.ModalBuilder, value: string | undefined}[] = [];
+ modals: {
+ buttonText: string;
+ emoji: string;
+ customId: string;
+ modal: Discord.ModalBuilder;
+ value: string | undefined;
+ }[] = [];
constructor(interaction: CommandInteraction | ButtonInteraction) {
this.interaction = interaction;
@@ -102,7 +108,7 @@
}
addModal(buttonText: string, emoji: string, customId: string, current: string, modal: Discord.ModalBuilder) {
modal.setCustomId(customId);
- this.modals.push({buttonText, emoji, customId, modal, value: current});
+ this.modals.push({ buttonText, emoji, customId, modal, value: current });
return this;
}
async send(editOnly?: boolean): Promise<{
@@ -110,7 +116,13 @@
cancelled?: boolean;
components?: Record<string, CustomBoolean<unknown>>;
newReason?: string;
- modals?: {buttonText: string, emoji: string, customId: string, modal: Discord.ModalBuilder, value: string | undefined}[];
+ modals?: {
+ buttonText: string;
+ emoji: string;
+ customId: string;
+ modal: Discord.ModalBuilder;
+ value: string | undefined;
+ }[];
}> {
let cancelled = false;
let success: boolean | undefined = undefined;
@@ -212,7 +224,7 @@
time: 300000
});
} catch (e) {
- success = false
+ success = false;
break;
}
if (component.customId === "yes") {
@@ -291,7 +303,12 @@
continue;
}
} else if (this.modals.map((m) => m.customId).includes(component.customId)) {
- const chosenModal = this.modals.find((component => m => m.customId === component.customId)(component));
+ const chosenModal = this.modals.find(
+ (
+ (component) => (m) =>
+ m.customId === component.customId
+ )(component)
+ );
await component.showModal(chosenModal!.modal);
await this.interaction.editReply({
embeds: [
@@ -364,7 +381,12 @@
const modals = this.modals;
const typedReturnValue = returnValue as
| { cancelled: true }
- | { success: boolean; components: Record<string, CustomBoolean<unknown>>; modals: typeof modals; newReason?: string }
+ | {
+ success: boolean;
+ components: Record<string, CustomBoolean<unknown>>;
+ modals: typeof modals;
+ newReason?: string;
+ }
| { newReason: string; components: Record<string, CustomBoolean<unknown>>; modals: typeof modals }
| { components: Record<string, CustomBoolean<unknown>>; modals: typeof modals };
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 62aee7c..19aa00b 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -836,9 +836,7 @@
}
}
-export class Plugins {
-
-}
+// export class Plugins {}
export interface GuildConfig {
id: string;