Reformat using prettier
diff --git a/src/commands/help.ts b/src/commands/help.ts
index 90ef133..fe829b9 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -22,163 +22,216 @@
import { getCommandByName, getCommandMentionByName } from "../utils/getCommandDataByName.js";
import getEmojiByName from "../utils/getEmojiByName.js";
-const command = new SlashCommandBuilder()
- .setName("help")
- .setDescription("Shows help for commands");
+const command = new SlashCommandBuilder().setName("help").setDescription("Shows help for commands");
-const styles: Record<string, {emoji: string}> = {
- "help": {emoji: "NUCLEUS.LOGO"},
- "mod": {emoji: "PUNISH.BAN.RED"},
- "nucleus": {emoji: "NUCLEUS.LOGO"},
- "privacy": {emoji: "NUCLEUS.LOGO"},
- "role": {emoji: "GUILD.ROLES.DELETE"},
- "rolemenu": {emoji: "GUILD.ROLES.DELETE"},
- "server": {emoji: "GUILD.RED"},
- "settings": {emoji: "GUILD.SETTINGS.RED"},
- "tag": {emoji: "PUNISH.NICKNAME.RED"},
- "tags": {emoji: "PUNISH.NICKNAME.RED"},
- "ticket": {emoji: "GUILD.TICKET.CLOSE"},
- "user": {emoji: "MEMBER.LEAVE"},
- "verify": {emoji: "CONTROL.REDTICK"}
-}
+const styles: Record<string, { emoji: string }> = {
+ help: { emoji: "NUCLEUS.LOGO" },
+ mod: { emoji: "PUNISH.BAN.RED" },
+ nucleus: { emoji: "NUCLEUS.LOGO" },
+ privacy: { emoji: "NUCLEUS.LOGO" },
+ role: { emoji: "GUILD.ROLES.DELETE" },
+ rolemenu: { emoji: "GUILD.ROLES.DELETE" },
+ server: { emoji: "GUILD.RED" },
+ settings: { emoji: "GUILD.SETTINGS.RED" },
+ tag: { emoji: "PUNISH.NICKNAME.RED" },
+ tags: { emoji: "PUNISH.NICKNAME.RED" },
+ ticket: { emoji: "GUILD.TICKET.CLOSE" },
+ user: { emoji: "MEMBER.LEAVE" },
+ verify: { emoji: "CONTROL.REDTICK" }
+};
const callback = async (interaction: CommandInteraction): Promise<void> => {
const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
const commands = client.fetchedCommands;
let closed = false;
- let currentPath: [string, string, string] = ["", "", ""]
+ let currentPath: [string, string, string] = ["", "", ""];
do {
- const commandRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("commandRow")
- .setPlaceholder("Select a command")
- .addOptions(
- ...commands.filter(command => command.type === ApplicationCommandType.ChatInput).map((command) => {
+ const commandRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("commandRow")
+ .setPlaceholder("Select a command")
+ .addOptions(
+ ...commands
+ .filter((command) => command.type === ApplicationCommandType.ChatInput)
+ .map((command) => {
const builder = new StringSelectMenuOptionBuilder()
.setLabel(capitalize(command.name))
.setValue(command.name)
.setDescription(command.description)
- .setDefault(currentPath[0] === command.name)
- if (styles[command.name]) builder.setEmoji(getEmojiByName(styles[command.name]!.emoji, "id") as APIMessageComponentEmoji)
- return builder
+ .setDefault(currentPath[0] === command.name);
+ if (styles[command.name])
+ builder.setEmoji(
+ getEmojiByName(styles[command.name]!.emoji, "id") as APIMessageComponentEmoji
+ );
+ return builder;
})
- )
+ )
);
- const subcommandGroupRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("subcommandGroupRow")
- );
- const subcommandRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("subcommandRow")
- );
- const embed = new EmojiEmbed()
- .setTitle("Help")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOGO")
+ const subcommandGroupRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder().setCustomId("subcommandGroupRow")
+ );
+ const subcommandRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder().setCustomId("subcommandRow")
+ );
+ const embed = new EmojiEmbed().setTitle("Help").setStatus("Danger").setEmoji("NUCLEUS.LOGO");
- if(currentPath[0] === "" || currentPath[0] === "help") {
+ if (currentPath[0] === "" || currentPath[0] === "help") {
embed.setDescription(
`Welcome to Nucleus\n\n` +
- `Select a command to get started${
- (interaction.member?.permissions as PermissionsBitField).has("ManageGuild") ?
- `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server` : ``
+ `Select a command to get started${
+ (interaction.member?.permissions as PermissionsBitField).has("ManageGuild")
+ ? `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server`
+ : ``
}\n\n\n` +
- `Nucleus is fully [open source](https://github.com/clicksminuteper/Nucleus), and all currently free features will remain free forever.\n\n` +
- `You can invite Nucleus to your server using ${getCommandMentionByName("nucleus/invite")}`
- )
+ `Nucleus is fully [open source](https://github.com/clicksminuteper/Nucleus), and all currently free features will remain free forever.\n\n` +
+ `You can invite Nucleus to your server using ${getCommandMentionByName("nucleus/invite")}`
+ );
} else {
- const currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
+ const currentData = getCommandByName(
+ currentPath.filter((value) => value !== "" && value !== "none").join("/")
+ );
const current = commands.find((command) => command.name === currentPath[0])!;
- let optionString = ``
+ let optionString = ``;
let options: (ApplicationCommandOption & {
nameLocalized?: string;
descriptionLocalized?: string;
})[] = [];
//options
- if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") {
- const Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
- const Op2 = Op.options!.find(option => option.name === currentPath[2])!
- options = Op2.options ?? []
- } else if(currentPath[1] !== "" && currentPath[1] !== "none") {
- let Op = current.options.find(option => option.name === currentPath[1])!
- if(Op.type === ApplicationCommandOptionType.SubcommandGroup) {
- options = []
+ if (
+ currentPath[1] !== "" &&
+ currentPath[1] !== "none" &&
+ currentPath[2] !== "" &&
+ currentPath[2] !== "none"
+ ) {
+ const Op = current.options.find(
+ (option) => option.name === currentPath[1]
+ )! as ApplicationCommandSubGroup;
+ const Op2 = Op.options!.find((option) => option.name === currentPath[2])!;
+ options = Op2.options ?? [];
+ } else if (currentPath[1] !== "" && currentPath[1] !== "none") {
+ let Op = current.options.find((option) => option.name === currentPath[1])!;
+ if (Op.type === ApplicationCommandOptionType.SubcommandGroup) {
+ options = [];
} else {
- Op = Op as ApplicationCommandSubCommand
- options = Op.options ?? []
+ Op = Op as ApplicationCommandSubCommand;
+ options = Op.options ?? [];
}
} else {
- options = current.options.filter(option => (option.type !== ApplicationCommandOptionType.SubcommandGroup) && (option.type !== ApplicationCommandOptionType.Subcommand));
+ options = current.options.filter(
+ (option) =>
+ option.type !== ApplicationCommandOptionType.SubcommandGroup &&
+ option.type !== ApplicationCommandOptionType.Subcommand
+ );
}
- for(const option of options) {
- optionString += `> ${option.name} (${ApplicationCommandOptionType[option.type]})- ${option.description}\n`
+ for (const option of options) {
+ optionString += `> ${option.name} (${ApplicationCommandOptionType[option.type]})- ${
+ option.description
+ }\n`;
}
- const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0]
+ const APICommand =
+ client.commands[
+ "commands/" + currentPath.filter((value) => value !== "" && value !== "none").join("/")
+ ]![0];
let allowedToRun = true;
- if(APICommand?.check) {
- allowedToRun = await APICommand.check(interaction as Interaction, true)
+ if (APICommand?.check) {
+ allowedToRun = await APICommand.check(interaction as Interaction, true);
}
embed.setDescription(
- `${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${currentData.mention}\n\n` +
- `> ${currentData.description}\n\n` +
- (APICommand ? (`${getEmojiByName(allowedToRun ? "CONTROL.TICK" : "CONTROL.CROSS")} You ${allowedToRun ? "" : "don't "}` +
- `have permission to use this command\n\n`) : "") +
- ((optionString.length > 0) ? "**Options:**\n" + optionString : "")
- )
- const subcommands = current.options.filter((option) => option.type === ApplicationCommandOptionType.Subcommand);
- const subcommandGroups = current.options.filter((option) => option.type === ApplicationCommandOptionType.SubcommandGroup);
+ `${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${
+ currentData.mention
+ }\n\n` +
+ `> ${currentData.description}\n\n` +
+ (APICommand
+ ? `${getEmojiByName(allowedToRun ? "CONTROL.TICK" : "CONTROL.CROSS")} You ${
+ allowedToRun ? "" : "don't "
+ }` + `have permission to use this command\n\n`
+ : "") +
+ (optionString.length > 0 ? "**Options:**\n" + optionString : "")
+ );
+ const subcommands = current.options.filter(
+ (option) => option.type === ApplicationCommandOptionType.Subcommand
+ );
+ const subcommandGroups = current.options.filter(
+ (option) => option.type === ApplicationCommandOptionType.SubcommandGroup
+ );
- if(subcommandGroups.length > 0) {
- subcommandGroupRow.components[0]!
- .addOptions(
- new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[1] === "none"),
- ...subcommandGroups.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name))
+ if (subcommandGroups.length > 0) {
+ subcommandGroupRow.components[0]!.addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Select a subcommand")
+ .setValue("none")
+ .setDefault(currentPath[1] === "none"),
+ ...subcommandGroups.map((option) =>
+ new StringSelectMenuOptionBuilder()
+ .setLabel(capitalize(option.name))
+ .setValue(option.name)
+ .setDefault(currentPath[1] === option.name)
)
- if(subcommandGroupRow.components[0]!.options.find((option) => option.data.default && option.data.value !== "none")) {
- const subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options ?? [];
- subcommandRow.components[0]!
- .addOptions(
- new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[2] === "none"),
- ...subsubcommands.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[2] === option.name))
+ );
+ if (
+ subcommandGroupRow.components[0]!.options.find(
+ (option) => option.data.default && option.data.value !== "none"
+ )
+ ) {
+ const subsubcommands =
+ (
+ subcommandGroups.find(
+ (option) => option.name === currentPath[1]
+ )! as ApplicationCommandSubGroup
+ ).options ?? [];
+ subcommandRow.components[0]!.addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Select a subcommand")
+ .setValue("none")
+ .setDefault(currentPath[2] === "none"),
+ ...subsubcommands.map((option) =>
+ new StringSelectMenuOptionBuilder()
+ .setLabel(capitalize(option.name))
+ .setValue(option.name)
+ .setDefault(currentPath[2] === option.name)
)
+ );
}
}
- if(subcommands.length > 0) {
- subcommandGroupRow.components[0]!
- .addOptions(
- ...subcommands.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name))
+ if (subcommands.length > 0) {
+ subcommandGroupRow.components[0]!.addOptions(
+ ...subcommands.map((option) =>
+ new StringSelectMenuOptionBuilder()
+ .setLabel(capitalize(option.name))
+ .setValue(option.name)
+ .setDefault(currentPath[1] === option.name)
)
+ );
}
}
const cmps = [commandRow];
- if(subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow);
- if(subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow);
+ if (subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow);
+ if (subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow);
await interaction.editReply({ embeds: [embed], components: cmps });
let i: StringSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent<ComponentType.StringSelect>({filter: (newInteraction) => interaction.user.id === newInteraction.user.id,time: 300000})
+ i = await m.awaitMessageComponent<ComponentType.StringSelect>({
+ filter: (newInteraction) => interaction.user.id === newInteraction.user.id,
+ time: 300000
+ });
} catch (e) {
closed = true;
continue;
}
await i.deferUpdate();
const value = i.values[0]!;
- switch(i.customId) {
+ switch (i.customId) {
case "commandRow": {
currentPath = [value, "", ""];
break;
}
case "subcommandGroupRow": {
- currentPath = [currentPath[0], value , ""];
+ currentPath = [currentPath[0], value, ""];
break;
}
case "subcommandRow": {
@@ -186,10 +239,8 @@
break;
}
}
-
} while (!closed);
};
-
export { command as command };
export { callback };
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index c5fcca5..af8006c 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -5,4 +5,4 @@
const subcommand = await command(name, description, `mod`);
-export { name, description, subcommand as command };
\ No newline at end of file
+export { name, description, subcommand as command };
diff --git a/src/commands/mod/about.ts b/src/commands/mod/about.ts
index 0a9d962..8736054 100644
--- a/src/commands/mod/about.ts
+++ b/src/commands/mod/about.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from '../../utils/defaults.js';
+import { LoadingEmbed } from "../../utils/defaults.js";
import type { HistorySchema } from "../../utils/database.js";
import Discord, {
CommandInteraction,
@@ -104,10 +104,7 @@
let history, current: TimelineSection;
history = await client.database.history.read(member.guild.id, member.id, currentYear);
history = history
- .sort(
- (a: { occurredAt: Date }, b: { occurredAt: Date }) =>
- b.occurredAt.getTime() - a.occurredAt.getTime()
- )
+ .sort((a: { occurredAt: Date }, b: { occurredAt: Date }) => b.occurredAt.getTime() - a.occurredAt.getTime())
.reverse();
let m: Message;
let refresh = false;
@@ -154,59 +151,62 @@
}
}
if (pageIndex === null) pageIndex = 0;
- let components: (ActionRowBuilder<Discord.StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[] = []
- if (openFilterPane) components = components.concat([
- new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
- new Discord.StringSelectMenuBuilder()
- .setMinValues(1)
- .setMaxValues(Object.keys(types).length)
- .setCustomId("filter")
- .setPlaceholder("Select events to show")
- .setOptions(...Object.entries(types).map(([key, value]) => new Discord.StringSelectMenuOptionBuilder()
- .setLabel(value.text)
- .setValue(key)
- .setDefault(filteredTypes.includes(key))
- .setEmoji(getEmojiByName(value.emoji, "id") as APIMessageComponentEmoji)
- )))
+ let components: (ActionRowBuilder<Discord.StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[] = [];
+ if (openFilterPane)
+ components = components.concat([
+ new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
+ new Discord.StringSelectMenuBuilder()
+ .setMinValues(1)
+ .setMaxValues(Object.keys(types).length)
+ .setCustomId("filter")
+ .setPlaceholder("Select events to show")
+ .setOptions(
+ ...Object.entries(types).map(([key, value]) =>
+ new Discord.StringSelectMenuOptionBuilder()
+ .setLabel(value.text)
+ .setValue(key)
+ .setDefault(filteredTypes.includes(key))
+ .setEmoji(getEmojiByName(value.emoji, "id") as APIMessageComponentEmoji)
+ )
+ )
+ )
+ ]);
+ components = components.concat([
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setCustomId("prevYear")
+ .setLabel((currentYear - 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId("prevPage").setLabel("Previous page").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder().setCustomId("today").setLabel("Today").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId("nextPage")
+ .setLabel("Next page")
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ new ButtonBuilder()
+ .setCustomId("nextYear")
+ .setLabel((currentYear + 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(currentYear === new Date().getFullYear())
+ ])
]);
- components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setCustomId("prevYear")
- .setLabel((currentYear - 1).toString())
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId("prevPage")
- .setLabel("Previous page")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("today")
- .setLabel("Today")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("nextPage")
- .setLabel("Next page")
- .setStyle(ButtonStyle.Primary)
- .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
- new ButtonBuilder()
- .setCustomId("nextYear")
- .setLabel((currentYear + 1).toString())
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(currentYear === new Date().getFullYear())
- ])])
- components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setLabel("Mod notes")
- .setCustomId("modNotes")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
- new ButtonBuilder()
- .setLabel("Filter")
- .setCustomId("openFilter")
- .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
- ])])
+ components = components.concat([
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setLabel("Mod notes")
+ .setCustomId("modNotes")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new ButtonBuilder()
+ .setLabel("Filter")
+ .setCustomId("openFilter")
+ .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
+ ])
+ ]);
const end =
"\n\nJanuary " +
@@ -227,7 +227,10 @@
)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : "No filters selected"
})
],
components: components
@@ -241,17 +244,26 @@
.setDescription(`**${currentYear}**\n\n*No events*`)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : "No filters selected"
})
],
components: components
- })
+ });
}
let i: MessageComponentInteraction;
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
interaction.editReply({
@@ -328,7 +340,9 @@
let timedOut = false;
while (!timedOut) {
note = await client.database.notes.read(member.guild.id, member.id);
- if (firstLoad && !note) { await showHistory(member, interaction); }
+ if (firstLoad && !note) {
+ await showHistory(member, interaction);
+ }
firstLoad = false;
m = (await interaction.editReply({
embeds: [
@@ -357,7 +371,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -424,13 +444,13 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
return true;
};
export { command, callback, check };
export const metadata = {
- longDescription: "Shows the moderation history (all previous bans, kicks, warns etc.), and moderator notes for a user.",
- premiumOnly: true,
-}
+ longDescription:
+ "Shows the moderation history (all previous bans, kicks, warns etc.), and moderator notes for a user.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index e8309fb..628b607 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,4 +1,12 @@
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle, SlashCommandSubcommandBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ User,
+ ButtonStyle,
+ SlashCommandSubcommandBuilder
+} from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
@@ -7,7 +15,6 @@
import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("ban")
@@ -22,7 +29,6 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
const { renderUser } = client.logger;
@@ -39,12 +45,13 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
- reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
+ reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
}) +
`The user **will${notify ? "" : " not"}** be notified\n` +
`${addPlurals(
- (interaction.options.get("delete")?.value as number | null) ?? 0, "day")
- } of messages will be deleted\n\n` +
+ (interaction.options.get("delete")?.value as number | null) ?? 0,
+ "day"
+ )} of messages will be deleted\n\n` +
`Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.addCustomBoolean(
@@ -66,15 +73,20 @@
else if (confirmation.success !== undefined) chosen = true;
else if (confirmation.newReason) reason = confirmation.newReason;
else if (confirmation.components) notify = confirmation.components["notify"]!.active;
- } while (!timedOut && !chosen)
+ } while (!timedOut && !chosen);
if (timedOut || !confirmation.success) return;
- reason = reason.length ? reason : null
+ reason = reason.length ? reason : null;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -92,14 +104,20 @@
components: []
};
if (config.moderation.ban.text && config.moderation.ban.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.ban.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -109,7 +127,7 @@
}
try {
const member = interaction.options.getMember("user") as GuildMember;
- const days: number = interaction.options.get("delete")?.value as number | null ?? 0;
+ const days: number = (interaction.options.get("delete")?.value as number | null) ?? 0;
member.ban({
deleteMessageSeconds: days * 24 * 60 * 60,
reason: reason ?? "*No reason provided*"
@@ -135,7 +153,9 @@
serverMemberCount: interaction.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -174,17 +194,17 @@
const member = interaction.member as GuildMember;
// Check if the user has ban_members permission
if (!member.permissions.has("BanMembers")) return "You do not have the *Ban Members* permission";
- if(partial) return true;
+ if (partial) return true;
const me = interaction.guild.members.me!;
let apply = interaction.options.getUser("user") as User | 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;
- let applyPos = 0
+ let applyPos = 0;
try {
- apply = await interaction.guild.members.fetch(apply.id) as GuildMember
+ apply = (await interaction.guild.members.fetch(apply.id)) as GuildMember;
applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
} catch {
- apply = apply as User
+ apply = apply as User;
}
// Do not allow banning the owner
if (member.id === interaction.guild.ownerId) return "You cannot ban the owner of the server";
@@ -204,6 +224,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Removes a member from the server - this will prevent them from rejoining until they are unbanned, and will delete a specified number of days of messages from them.",
- premiumOnly: true,
-}
+ longDescription:
+ "Removes a member from the server - this will prevent them from rejoining until they are unbanned, and will delete a specified number of days of messages from them.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 059bdb2..c4f1867 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,5 +1,12 @@
-import { LinkWarningFooter } from '../../utils/defaults.js';
-import { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandSubcommandBuilder } from "discord.js";
+import { LinkWarningFooter } from "../../utils/defaults.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ SlashCommandSubcommandBuilder
+} from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
import type Discord from "discord.js";
@@ -31,9 +38,8 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
- reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
- }) +
- `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
+ reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
+ }) + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
@@ -56,14 +62,19 @@
else if (confirmation.components) {
notify = confirmation.components["notify"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !confirmation.success) return;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -81,14 +92,20 @@
components: []
};
if (config.moderation.kick.text && config.moderation.kick.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.kick.text)
- .setURL(config.moderation.kick.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.kick.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -101,12 +118,14 @@
const member = interaction.options.getMember("user") as GuildMember;
await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const timeInServer = member.joinedTimestamp ? entry(
- (Date.now() - member.joinedTimestamp).toString(),
- humanizeDuration(Date.now() - member.joinedTimestamp, {
- round: true
- })
- ) : entry(null, "*Unknown*")
+ const timeInServer = member.joinedTimestamp
+ ? entry(
+ (Date.now() - member.joinedTimestamp).toString(),
+ humanizeDuration(Date.now() - member.joinedTimestamp, {
+ round: true
+ })
+ )
+ : entry(null, "*Unknown*");
const data = {
meta: {
type: "memberKick",
@@ -119,7 +138,7 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: undefined as (unknown | typeof entry),
+ joined: undefined as unknown | typeof entry,
kicked: entry(Date.now().toString(), renderDelta(Date.now())),
kickedBy: entry(interaction.user.id, renderUser(interaction.user)),
reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
@@ -127,22 +146,18 @@
serverMemberCount: member.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: member.guild.id
}
};
if (member.joinedTimestamp) {
- data.list.joined = entry(member.joinedTimestamp.toString(), renderDelta(member.joinedTimestamp))
+ data.list.joined = entry(member.joinedTimestamp.toString(), renderDelta(member.joinedTimestamp));
}
- await client.database.history.create(
- "kick",
- interaction.guild.id,
- member.user,
- interaction.user,
- reason
- )
+ await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
log(data);
} catch {
await interaction.editReply({
@@ -203,5 +218,5 @@
export { command, callback, check };
export const metadata = {
longDescription: "Removes a member from the server. They will be able to rejoin if they have an invite link.",
- premiumOnly: true,
-}
+ premiumOnly: true
+};
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index c795456..39c9e5e 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -49,12 +49,11 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
- const time: {days: number, hours: number, minutes: number, seconds: number} = {
+ const time: { days: number; hours: number; minutes: number; seconds: number } = {
days: (interaction.options.get("days")?.value as number | null) ?? 0,
hours: (interaction.options.get("hours")?.value as number | null) ?? 0,
minutes: (interaction.options.get("minutes")?.value as number | null) ?? 0,
@@ -79,8 +78,14 @@
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder().setCustomId("1m").setLabel("1 Minute").setStyle(ButtonStyle.Secondary),
- new Discord.ButtonBuilder().setCustomId("10m").setLabel("10 Minutes").setStyle(ButtonStyle.Secondary),
- new Discord.ButtonBuilder().setCustomId("30m").setLabel("30 Minutes").setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("10m")
+ .setLabel("10 Minutes")
+ .setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("30m")
+ .setLabel("30 Minutes")
+ .setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("1h").setLabel("1 Hour").setStyle(ButtonStyle.Secondary)
]),
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -103,7 +108,9 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => {return i.user.id === interaction.user.id && i.channelId === interaction.channelId},
+ filter: (i) => {
+ return i.user.id === interaction.user.id && i.channelId === interaction.channelId;
+ },
time: 300000
});
} catch {
@@ -178,7 +185,7 @@
time: `${humanizeDuration(muteTime * 1000, {
round: true
})}`,
- reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
+ reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
}) +
"The user will be " +
serverSettingsDescription +
@@ -190,7 +197,8 @@
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ async () =>
+ await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
null,
"CONTROL.TICKET",
@@ -217,13 +225,22 @@
notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !confirmation.success) return;
- const status: {timeout: boolean | null, role: boolean | null, dm: boolean | null} = {timeout: null, role: null, dm: null};
+ const status: { timeout: boolean | null; role: boolean | null; dm: boolean | null } = {
+ timeout: null,
+ role: null,
+ dm: null
+ };
let dmMessage;
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -234,28 +251,39 @@
.setTitle("Muted")
.setDescription(
`You have been muted in ${interaction.guild.name}` +
- (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") + "\n\n" +
- `You will be unmuted at: <t:${Math.round(Date.now() / 1000) + muteTime}:D> at ` +
- `<t:${Math.round(Date.now() / 1000) + muteTime}:T> (<t:${Math.round(Date.now() / 1000) + muteTime
- }:R>)` + "\n\n" +
- (createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
- : "")
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") +
+ "\n\n" +
+ `You will be unmuted at: <t:${Math.round(Date.now() / 1000) + muteTime}:D> at ` +
+ `<t:${Math.round(Date.now() / 1000) + muteTime}:T> (<t:${
+ Math.round(Date.now() / 1000) + muteTime
+ }:R>)` +
+ "\n\n" +
+ (createAppealTicket
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
+ : "")
)
.setStatus("Danger")
],
components: []
- }
+ };
if (config.moderation.mute.text && config.moderation.mute.link) {
messageData.embeds[0]!.setFooter(LinkWarningFooter);
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
- .setStyle(ButtonStyle.Link)
- .setLabel(config.moderation.mute.text)
- .setURL(config.moderation.mute.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setStyle(ButtonStyle.Link)
+ .setLabel(config.moderation.mute.text)
+ .setURL(
+ config.moderation.mute.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
)
- )
- };
+ );
+ }
dmMessage = await member.send(messageData);
status.dm = true;
}
@@ -267,11 +295,15 @@
await member.timeout(muteTime * 1000, reason || "*No reason provided*");
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("naturalUnmute", (Date.now() + muteTime * 1000).toString(), {
- guild: interaction.guild.id,
- user: member.id,
- expires: Date.now() + muteTime * 1000
- });
+ await client.database.eventScheduler.schedule(
+ "naturalUnmute",
+ (Date.now() + muteTime * 1000).toString(),
+ {
+ guild: interaction.guild.id,
+ user: member.id,
+ expires: Date.now() + muteTime * 1000
+ }
+ );
}
} else {
status.timeout = true;
@@ -293,7 +325,7 @@
} catch {
status.role = false;
}
- const countTrue = (items: (boolean | null)[]) => items.filter(item => item === true).length;
+ const countTrue = (items: (boolean | null)[]) => items.filter((item) => item === true).length;
const requiredPunishments = countTrue([config.moderation.mute.timeout, config.moderation.mute.role !== null]);
const actualPunishments = countTrue([status.timeout, status.role]);
@@ -301,7 +333,8 @@
if (requiredPunishments !== actualPunishments) {
const messages = [];
if (config.moderation.mute.timeout) messages.push(`The member was ${status.timeout ? "" : "not "}timed out`);
- if (config.moderation.mute.role !== null) messages.push(`The member was ${status.role ? "" : "not "}given the mute role`);
+ if (config.moderation.mute.role !== null)
+ messages.push(`The member was ${status.role ? "" : "not "}given the mute role`);
messages.push(`The member was not sent a DM`);
if (dmMessage && actualPunishments === 0) await dmMessage.delete();
await interaction.editReply({
@@ -310,8 +343,10 @@
.setEmoji("PUNISH.MUTE." + (actualPunishments > 0 ? "YELLOW" : "RED"))
.setTitle("Mute")
.setDescription(
- "Mute " + (actualPunishments > 0 ? "partially" : "failed") + ":\n" +
- messages.map(message => `> ${message}`).join("\n")
+ "Mute " +
+ (actualPunishments > 0 ? "partially" : "failed") +
+ ":\n" +
+ messages.map((message) => `> ${message}`).join("\n")
)
.setStatus(actualPunishments > 0 ? "Warning" : "Danger")
],
@@ -330,16 +365,15 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- mutedUntil: entry(
- (Date.now() + muteTime * 1000).toString(),
- renderDelta(Date.now() + muteTime * 1000)
- ),
+ mutedUntil: entry((Date.now() + muteTime * 1000).toString(), renderDelta(Date.now() + muteTime * 1000)),
muted: entry(new Date().getTime.toString(), renderDelta(Date.now() - 1000)),
mutedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
reason: entry(reason, reason ? reason : "*No reason provided*")
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -353,10 +387,11 @@
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle("Mute")
.setDescription(
- "The member was muted" + (failed ? ", but could not be notified" : "") +
- (createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
- : "")
+ "The member was muted" +
+ (failed ? ", but could not be notified" : "") +
+ (createAppealTicket
+ ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ : "")
)
.setStatus(failed ? "Warning" : "Success")
],
@@ -393,6 +428,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Stops a member from being able to send messages or join voice channels for a specified amount of time.",
- premiumOnly: true,
-}
+ longDescription:
+ "Stops a member from being able to send messages or join voice channels for a specified amount of time.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 5511d19..8b33551 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,4 +1,4 @@
-import { LinkWarningFooter } from './../../utils/defaults.js';
+import { LinkWarningFooter } from "./../../utils/defaults.js";
import { ActionRowBuilder, ButtonBuilder, CommandInteraction, GuildMember, ButtonStyle, Message } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -8,15 +8,14 @@
import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
-const command = (builder: SlashCommandSubcommandBuilder) => builder
- .setName("nick")
- .setDescription("Changes a users nickname")
- .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
- .addStringOption((option) =>
- option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
- );
-
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder
+ .setName("nick")
+ .setDescription("Changes a users nickname")
+ .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
+ .addStringOption((option) =>
+ option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
+ );
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
@@ -35,19 +34,27 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
"new nickname": `${
- interaction.options.get("name")?.value as string ? interaction.options.get("name")?.value as string : "*No nickname*"
+ (interaction.options.get("name")?.value as string)
+ ? (interaction.options.get("name")?.value as string)
+ : "*No nickname*"
}`
}) +
- `Are you sure you want to ${interaction.options.get("name")?.value as string ? "change" : "clear"} <@!${
- (interaction.options.getMember("user") as GuildMember).id
- }>'s nickname?`
+ `Are you sure you want to ${
+ (interaction.options.get("name")?.value as string) ? "change" : "clear"
+ } <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`
)
.setColor("Danger")
.addCustomBoolean(
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild!.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, "Nickname changed"),
+ async () =>
+ await create(
+ interaction.guild!,
+ interaction.options.getUser("user")!,
+ interaction.user,
+ "Nickname changed"
+ ),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -69,7 +76,7 @@
if (confirmation.cancelled) timedOut = true;
else if (confirmation.success !== undefined) success = true;
else if (confirmation.components) {
- notify = confirmation.components['notify']!.active;
+ notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
} while (!timedOut && !success);
@@ -88,29 +95,38 @@
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(
- `Your nickname was ${interaction.options.get("name")?.value as string ? "changed" : "cleared"} in ${
- interaction.guild!.name
- }.` +
- (interaction.options.get("name")?.value as string
+ `Your nickname was ${
+ (interaction.options.get("name")?.value as string) ? "changed" : "cleared"
+ } in ${interaction.guild!.name}.` +
+ ((interaction.options.get("name")?.value as string)
? `\nIt is now: ${interaction.options.get("name")?.value as string}`
: "") +
"\n\n" +
(createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Danger")
- ], components: []
+ ],
+ components: []
};
if (config.moderation.nick.text && config.moderation.nick.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.nick.text)
- .setURL(config.moderation.nick.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.nick.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -166,7 +182,9 @@
updatedBy: entry(interaction.user.id, renderUser(interaction.user))
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild!.id
@@ -221,6 +239,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Changes the nickname of a member. This is the name that shows in the member list and on messages.",
- premiumOnly: true,
-}
+ longDescription:
+ "Changes the nickname of a member. This is the name that shows in the member list and on messages.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index a1b094e..2c8129e 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,12 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle, ButtonBuilder, Message } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildChannel,
+ GuildMember,
+ TextChannel,
+ ButtonStyle,
+ ButtonBuilder,
+ Message
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -27,7 +35,7 @@
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
- const user = (interaction.options.getMember("user") as GuildMember | null);
+ const user = interaction.options.getMember("user") as GuildMember | null;
const channel = interaction.channel as GuildChannel;
if (!channel.isTextBased()) {
return await interaction.reply({
@@ -93,7 +101,8 @@
let component;
try {
component = m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch (e) {
@@ -112,7 +121,7 @@
if (user) {
ms = ms.filter((m) => m.author.id === user.id);
}
- messages = (await (channel as TextChannel).bulkDelete(ms, true)).map(m => m as Discord.Message);
+ messages = (await (channel as TextChannel).bulkDelete(ms, true)).map((m) => m as Discord.Message);
});
deleted = deleted.concat(messages);
}
@@ -133,7 +142,7 @@
interaction.guild.id,
user.user,
interaction.user,
- (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
+ (interaction.options.get("reason")?.value as string | null) ?? "*No reason provided*",
null,
null,
deleted.length.toString()
@@ -160,7 +169,11 @@
}
};
log(data);
- const newOut = await client.database.transcripts.createTranscript(deleted, interaction, interaction.member as GuildMember);
+ const newOut = await client.database.transcripts.createTranscript(
+ deleted,
+ interaction,
+ interaction.member as GuildMember
+ );
const transcript = client.database.transcripts.toHumanReadable(newOut);
const attachmentObject = {
attachment: Buffer.from(transcript),
@@ -188,7 +201,8 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch {
@@ -227,7 +241,11 @@
keyValueList({
channel: `<#${channel.id}>`,
amount: (interaction.options.get("amount")?.value as number).toString(),
- reason: `\n> ${interaction.options.get("reason")?.value ? interaction.options.get("reason")?.value : "*No reason provided*"}`
+ reason: `\n> ${
+ interaction.options.get("reason")?.value
+ ? interaction.options.get("reason")?.value
+ : "*No reason provided*"
+ }`
})
)
.setColor("Danger")
@@ -282,7 +300,7 @@
interaction.guild.id,
user.user,
interaction.user,
- (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
+ (interaction.options.get("reason")?.value as string | null) ?? "*No reason provided*",
null,
null,
messages.size.toString()
@@ -309,14 +327,19 @@
}
};
log(data);
- const messageArray: Message[] = messages.filter(message => !(
- message!.components.some(
- component => component.components.some(
- child => child.customId?.includes("transcript") ?? false
- )
+ const messageArray: Message[] = messages
+ .filter(
+ (message) =>
+ !message!.components.some((component) =>
+ component.components.some((child) => child.customId?.includes("transcript") ?? false)
+ )
)
- )).map(message => message as Message);
- const newOut = await client.database.transcripts.createTranscript(messageArray, interaction, interaction.member as GuildMember);
+ .map((message) => message as Message);
+ const newOut = await client.database.transcripts.createTranscript(
+ messageArray,
+ interaction,
+ interaction.member as GuildMember
+ );
const [code, key, iv] = await client.database.transcripts.create(newOut);
@@ -330,8 +353,11 @@
],
components: [
new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`).setDisabled(!code),
-
+ new ButtonBuilder()
+ .setLabel("View")
+ .setStyle(ButtonStyle.Link)
+ .setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`)
+ .setDisabled(!code)
])
]
});
@@ -355,6 +381,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Deletes a specified amount of messages from a channel, optionally from a specific user. Without an amount, you can repeatedly choose a number of messages to delete.",
- premiumOnly: true,
-}
+ longDescription:
+ "Deletes a specified amount of messages from a channel, optionally from a specific user. Without an amount, you can repeatedly choose a number of messages to delete.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index f282e82..ba88c00 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -16,25 +16,25 @@
.setDescription("The delay between messages")
.setRequired(false)
.addChoices(
- {name: "Off", value: "0"},
- {name: "5 seconds", value: "5"},
- {name: "10 seconds", value: "10"},
- {name: "15 seconds", value: "15"},
- {name: "30 seconds", value: "30"},
- {name: "1 minute", value: "60"},
- {name: "2 minutes", value: "120"},
- {name: "5 minutes", value: "300"},
- {name: "10 minutes", value: "600"},
- {name: "15 minutes", value: "900"},
- {name: "30 minutes", value: "1800"},
- {name: "1 hour", value: "3600"},
- {name: "2 hours", value: "7200"},
- {name: "6 hours", value: "21600"}
+ { name: "Off", value: "0" },
+ { name: "5 seconds", value: "5" },
+ { name: "10 seconds", value: "10" },
+ { name: "15 seconds", value: "15" },
+ { name: "30 seconds", value: "30" },
+ { name: "1 minute", value: "60" },
+ { name: "2 minutes", value: "120" },
+ { name: "5 minutes", value: "300" },
+ { name: "10 minutes", value: "600" },
+ { name: "15 minutes", value: "900" },
+ { name: "30 minutes", value: "1800" },
+ { name: "1 hour", value: "3600" },
+ { name: "2 hours", value: "7200" },
+ { name: "6 hours", value: "21600" }
)
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
- let time = parseInt(interaction.options.get("time")?.value as string || "0");
+ let time = parseInt((interaction.options.get("time")?.value as string) || "0");
if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) {
time = 10;
}
@@ -82,13 +82,15 @@
if (!member.permissions.has("ManageChannels")) return "You do not have the *Manage Channels* permission";
if (partial) return true;
// Check if Nucleus can set the slowmode
- if (!interaction.guild!.members.me!.permissions.has("ManageChannels")) return "I do not have the *Manage Channels* permission";
+ if (!interaction.guild!.members.me!.permissions.has("ManageChannels"))
+ return "I do not have the *Manage Channels* permission";
// Allow slowmode
return true;
};
export { command, callback, check };
export const metadata = {
- longDescription: "Stops members from being able to send messages without waiting a certain amount of time between messages.",
- premiumOnly: true,
-}
+ longDescription:
+ "Stops members from being able to send messages without waiting a certain amount of time between messages.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 1b404c9..cd03d1a 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,4 +1,11 @@
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ User,
+ ButtonStyle
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -8,7 +15,6 @@
import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("softban")
@@ -23,7 +29,6 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
const { renderUser } = client.logger;
@@ -40,12 +45,13 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
- reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
+ reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
}) +
`The user **will${notify ? "" : " not"}** be notified\n` +
`${addPlurals(
- (interaction.options.get("delete")?.value as number | null) ?? 0, "day")
- } of messages will be deleted\n\n` +
+ (interaction.options.get("delete")?.value as number | null) ?? 0,
+ "day"
+ )} of messages will be deleted\n\n` +
`Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.addCustomBoolean(
@@ -67,15 +73,20 @@
else if (confirmation.success !== undefined) chosen = true;
else if (confirmation.newReason) reason = confirmation.newReason;
else if (confirmation.components) notify = confirmation.components["notify"]!.active;
- } while (!timedOut && !chosen)
+ } while (!timedOut && !chosen);
if (timedOut || !confirmation.success) return;
- reason = reason.length ? reason : null
+ reason = reason.length ? reason : null;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -93,14 +104,20 @@
components: []
};
if (config.moderation.softban.text && config.moderation.softban.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.softban.text)
- .setURL(config.moderation.softban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.softban.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -110,7 +127,7 @@
}
try {
const member = interaction.options.getMember("user") as GuildMember;
- const days: number = interaction.options.get("delete")?.value as number | null ?? 0;
+ const days: number = (interaction.options.get("delete")?.value as number | null) ?? 0;
member.ban({
deleteMessageSeconds: days * 24 * 60 * 60,
reason: reason ?? "*No reason provided*"
@@ -137,7 +154,9 @@
serverMemberCount: interaction.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -181,12 +200,12 @@
let apply = interaction.options.getUser("user") as User | 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;
- let applyPos = 0
+ let applyPos = 0;
try {
- apply = await interaction.guild.members.fetch(apply.id) as GuildMember
+ apply = (await interaction.guild.members.fetch(apply.id)) as GuildMember;
applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
} catch {
- apply = apply as User
+ apply = apply as User;
}
// Do not allow banning the owner
if (member.id === interaction.guild.ownerId) return "You cannot softban the owner of the server";
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 40f4504..7397414 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -48,7 +48,13 @@
try {
await interaction.guild.members.unban(resolved.user as User, "Unban");
const member = resolved.user as User;
- await client.database.history.create("unban", interaction.guild.id, member, interaction.user, "No reason provided");
+ await client.database.history.create(
+ "unban",
+ interaction.guild.id,
+ member,
+ interaction.user,
+ "No reason provided"
+ );
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 8562c4c..f248a3b 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -29,8 +29,7 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
reason: `\n> ${reason ? reason : "*No reason provided*"}`
- }) +
- `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
+ }) + `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
@@ -115,7 +114,9 @@
unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -139,8 +140,7 @@
if (!interaction.guild) return;
const member = interaction.member as GuildMember;
// Check if the user has moderate_members permission
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
if (partial) return true;
const me = interaction.guild.members.me!;
const apply = interaction.options.getMember("user") as GuildMember;
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ef62816..41f34b9 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaults.js';
+import { LoadingEmbed } from "./../../utils/defaults.js";
import Discord, {
CommandInteraction,
GuildMember,
@@ -23,20 +23,19 @@
.addUserOption((option) => option.setName("member").setDescription("The member to view as").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
+ const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
-
- let channels: Record<string, GuildBasedChannel[]> = {"": []};
+ let channels: Record<string, GuildBasedChannel[]> = { "": [] };
const channelCollection = await interaction.guild!.channels.fetch();
- channelCollection.forEach(channel => {
+ channelCollection.forEach((channel) => {
if (!channel) return; // if no channel
if (channel.type === Discord.ChannelType.GuildCategory) {
- if(!channels[channel!.id]) channels[channel!.id] = [];
+ if (!channels[channel!.id]) channels[channel!.id] = [];
} else if (channel.parent) {
if (!channels[channel.parent.id]) channels[channel.parent.id] = [channel];
- else (channels[channel.parent.id as string])!.push(channel);
+ else channels[channel.parent.id as string]!.push(channel);
} else {
channels[""]!.push(channel);
}
@@ -47,7 +46,11 @@
for (const category in channels) {
channels[category] = channels[category]!.sort((a: GuildBasedChannel, b: GuildBasedChannel) => {
- const disallowedTypes = [Discord.ChannelType.PublicThread, Discord.ChannelType.PrivateThread, Discord.ChannelType.AnnouncementThread];
+ const disallowedTypes = [
+ Discord.ChannelType.PublicThread,
+ Discord.ChannelType.PrivateThread,
+ Discord.ChannelType.AnnouncementThread
+ ];
if (disallowedTypes.includes(a.type) || disallowedTypes.includes(b.type)) return 0;
a = a as NonThreadGuildBasedChannel;
b = b as NonThreadGuildBasedChannel;
@@ -64,7 +67,11 @@
}
for (const category in channels) {
channels[category] = channels[category]!.filter((c) => {
- return !(c.type === Discord.ChannelType.PublicThread || c.type === Discord.ChannelType.PrivateThread || c.type === Discord.ChannelType.AnnouncementThread)
+ return !(
+ c.type === Discord.ChannelType.PublicThread ||
+ c.type === Discord.ChannelType.PrivateThread ||
+ c.type === Discord.ChannelType.AnnouncementThread
+ );
});
}
channels = Object.fromEntries(Object.entries(channels).filter(([_, v]) => v.length > 0));
@@ -81,12 +88,12 @@
if (last25.length > 0) categoryNames25.push(last25);
const channelTypeEmoji: Record<number, string> = {
- 0: "GUILD_TEXT", // Text channel
- 2: "GUILD_VOICE", // Voice channel
- 5: "GUILD_NEWS", // Announcement channel
- 13: "GUILD_STAGE_VOICE", // Stage channel
- 15: "FORUM", // Forum channel
- 99: "RULES" // Rules channel
+ 0: "GUILD_TEXT", // Text channel
+ 2: "GUILD_VOICE", // Voice channel
+ 5: "GUILD_NEWS", // Announcement channel
+ 13: "GUILD_STAGE_VOICE", // Stage channel
+ 15: "FORUM", // Forum channel
+ 99: "RULES" // Rules channel
};
const NSFWAvailable: number[] = [0, 2, 5, 13];
const rulesChannel = interaction.guild!.rulesChannel?.id;
@@ -94,12 +101,12 @@
async function nameFromChannel(channel: GuildBasedChannel): Promise<string> {
let channelType: Discord.ChannelType | 99 = channel.type;
if (channelType === Discord.ChannelType.GuildCategory) return "";
- if (channel.id === rulesChannel) channelType = 99
+ if (channel.id === rulesChannel) channelType = 99;
let threads: Discord.ThreadChannel[] = [];
if ("threads" in channel) {
threads = channel.threads.cache.toJSON().map((t) => t as Discord.ThreadChannel);
}
- const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType)
+ const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType);
const emojiName = channelTypeEmoji[channelType.valueOf()] + (nsfw ? "_NSFW" : "");
const emoji = getEmojiByName("ICONS.CHANNEL." + (threads.length ? "THREAD_CHANNEL" : emojiName));
let current = `${emoji} ${channel.name}`;
@@ -118,46 +125,59 @@
description += `${await nameFromChannel(channel)}\n`;
}
- const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] = categoryNames25.map(
- (categories, set) => { return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(new StringSelectMenuBuilder()
- .setCustomId("category")
- .setMinValues(1)
- .setMaxValues(1)
- .setOptions(categories.map((c, i) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(c)
- .setValue((set * 25 + i).toString())
- .setEmoji(getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji) // Again, this is valid but TS doesn't think so
- .setDefault((set * 25 + i) === page)
- }))
- )}
+ const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] =
+ categoryNames25.map((categories, set) => {
+ return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("category")
+ .setMinValues(1)
+ .setMaxValues(1)
+ .setOptions(
+ categories.map((c, i) => {
+ return new StringSelectMenuOptionBuilder()
+ .setLabel(c)
+ .setValue((set * 25 + i).toString())
+ .setEmoji(
+ getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji
+ ) // Again, this is valid but TS doesn't think so
+ .setDefault(set * 25 + i === page);
+ })
+ )
+ );
+ });
+
+ const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu;
+ components.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
+ new ButtonBuilder()
+ .setCustomId("right")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === categoryIDs.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ )
);
- const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu
- components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === 0)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
- new ButtonBuilder()
- .setCustomId("right")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === categoryIDs.length - 1)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- ));
-
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
- ], components: components
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
+ ],
+ components: components
});
let i;
try {
- i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 30000});
+ i = await m.awaitMessageComponent({
+ filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id,
+ time: 30000
+ });
} catch (e) {
closed = true;
continue;
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index ea4f084..5d1bd94 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -32,15 +32,15 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
- }) +
- `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
+ }) + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ async () =>
+ await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -67,13 +67,18 @@
notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !success) return;
let dmSent = false;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -87,7 +92,9 @@
(reason ? ` for:\n${reason}` : ".\n*No reason was provided*") +
"\n\n" +
(createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Danger")
@@ -95,14 +102,20 @@
components: []
};
if (config.moderation.warn.text && config.moderation.warn.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.warn.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -128,7 +141,9 @@
reason: reason ? reason : "*No reason provided*"
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -152,7 +167,9 @@
.setDescription(
"The user was warned" +
(createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ ? ` and an appeal ticket was opened in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Success")
@@ -173,7 +190,10 @@
],
components: [
new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
- new Discord.ButtonBuilder().setCustomId("log").setLabel("Ignore and log").setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("log")
+ .setLabel("Ignore and log")
+ .setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder()
.setCustomId("here")
.setLabel("Warn here")
@@ -190,7 +210,8 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch (e) {
@@ -227,7 +248,9 @@
.setDescription(
"The user was warned" +
(createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ ? ` and an appeal ticket was opened in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Success")
@@ -282,9 +305,8 @@
const check = (interaction: CommandInteraction, partial: boolean = false) => {
if (!interaction.guild) return;
const member = interaction.member as GuildMember;
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
- if(partial) return true;
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
+ if (partial) return true;
const apply = interaction.options.getMember("user") as GuildMember | null;
if (apply === null) return "That member is not in the server";
const memberPos = member.roles.cache.size ? member.roles.highest.position : 0;
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index 270ee62..d05e265 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -1,4 +1,4 @@
-import type { CommandInteraction } from 'discord.js';
+import type { CommandInteraction } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import guide from "../../reflex/guide.js";
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index b89425a..6805adb 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -21,7 +21,9 @@
.setLabel("Invite")
.setStyle(ButtonStyle.Link)
.setURL(
- `https://discord.com/api/oauth2/authorize?client_id=${client.user!.id}&permissions=295157886134&scope=bot%20applications.commands`
+ `https://discord.com/api/oauth2/authorize?client_id=${
+ client.user!.id
+ }&permissions=295157886134&scope=bot%20applications.commands`
)
])
],
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 3e02a8f..62988bb 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -19,8 +19,8 @@
.setTitle("Ping")
.setDescription(
`**Ping:** \`${ping}ms\`\n` +
- `**To Discord:** \`${client.ws.ping}ms\`\n` +
- `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
+ `**To Discord:** \`${client.ws.ping}ms\`\n` +
+ `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
)
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setStatus("Danger")
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index c431c8e..721bc5c 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -1,4 +1,14 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, ComponentType, Message, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js";
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ CommandInteraction,
+ ComponentType,
+ Message,
+ StringSelectMenuBuilder,
+ StringSelectMenuInteraction
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -13,53 +23,54 @@
let closed = false;
do {
const dbUser = await client.database.premium.fetchUser(interaction.user.id);
- if(!dbUser) {
- await interaction.editReply({embeds: [
- new EmojiEmbed()
- .setTitle("Premium")
- .setDescription(`*You do not have premium! You can't activate premium on any servers.*` + firstDescription)
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ]});
+ if (!dbUser) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Premium")
+ .setDescription(
+ `*You do not have premium! You can't activate premium on any servers.*` + firstDescription
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ]
+ });
return;
}
const premiumGuilds = dbUser.appliesTo.map((guildID) => {
const guild = client.guilds.cache.get(guildID);
- if(!guild) return undefined;
+ if (!guild) return undefined;
return guild.name;
});
const options = premiumGuilds.filter((guild) => guild !== undefined) as string[];
- const removeRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("currentPremium")
- .setPlaceholder("Select a server to remove premium from")
- .setDisabled(premiumGuilds.length === 0)
- .addOptions(options.slice(0, Math.min(options.length, 24)).map((guild) => {
- return {label: guild, value: guild}
- }))
- );
- const cancel = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("cancel")
- .setLabel("Close")
- .setStyle(ButtonStyle.Danger)
- );
+ const removeRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("currentPremium")
+ .setPlaceholder("Select a server to remove premium from")
+ .setDisabled(premiumGuilds.length === 0)
+ .addOptions(
+ options.slice(0, Math.min(options.length, 24)).map((guild) => {
+ return { label: guild, value: guild };
+ })
+ )
+ );
+ const cancel = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("cancel").setLabel("Close").setStyle(ButtonStyle.Danger)
+ );
const components: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] = [cancel];
- if(options.length > 0) components.unshift(removeRow);
- await interaction.editReply(
- {
+ if (options.length > 0) components.unshift(removeRow);
+ await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Premium")
.setDescription(
`*You have premium on the following servers:*\n\n` +
- (options.length > 0 ? options.join(', ') : `You have not activated premium in any guilds`) +
- firstDescription)
+ (options.length > 0 ? options.join(", ") : `You have not activated premium in any guilds`) +
+ firstDescription
+ )
.setEmoji("NUCLEUS.LOGO")
.setStatus("Success")
],
@@ -69,43 +80,66 @@
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
const filter = (i: StringSelectMenuInteraction | ButtonInteraction) => i.user.id === interaction.user.id;
- i = await msg.awaitMessageComponent<ComponentType.StringSelect | ComponentType.Button>({time: 300000, filter})
+ i = await msg.awaitMessageComponent<ComponentType.StringSelect | ComponentType.Button>({
+ time: 300000,
+ filter
+ });
} catch (e) {
await interaction.deleteReply();
closed = true;
break;
}
await i.deferUpdate();
- if(i.isButton()) {
+ if (i.isButton()) {
closed = true;
} else {
const response = client.database.premium.removePremium(interaction.user.id, i.values[0]!);
- console.log(response)
+ console.log(response);
}
} while (!closed);
await interaction.deleteReply();
-}
+};
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (interaction.guild) client.database.premium.hasPremium(interaction.guild.id).finally(() => {});
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
- const member = await (await interaction.client.guilds.fetch("684492926528651336")).members.fetch(interaction.user.id).catch(() => {
- interaction.editReply({ embeds: [
- new EmojiEmbed()
- .setTitle("Premium")
- .setDescription(`*You are not currently in the Clicks Server. To gain access to premium please join.*` + firstDescription)
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(ButtonStyle.Link).setLabel("Join").setURL("https://discord.gg/bPaNnxe"))] });
- })
+ const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
+ const member = await (await interaction.client.guilds.fetch("684492926528651336")).members
+ .fetch(interaction.user.id)
+ .catch(() => {
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Premium")
+ .setDescription(
+ `*You are not currently in the Clicks Server. To gain access to premium please join.*` +
+ firstDescription
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setStyle(ButtonStyle.Link)
+ .setLabel("Join")
+ .setURL("https://discord.gg/bPaNnxe")
+ )
+ ]
+ });
+ });
if (!member) return;
- const firstDescription = "\n\nPremium allows servers of your choice to get access to extra features for a fixed price per month.\nThis includes:\n" +
- `${getEmojiByName("MOD.IMAGES.TOOSMALL")} Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n` +
- `${getEmojiByName("GUILD.TICKET.ARCHIVED")} Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n`
- const dbMember = await client.database.premium.fetchUser(interaction.user.id)
+ const firstDescription =
+ "\n\nPremium allows servers of your choice to get access to extra features for a fixed price per month.\nThis includes:\n" +
+ `${getEmojiByName(
+ "MOD.IMAGES.TOOSMALL"
+ )} Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n` +
+ `${getEmojiByName(
+ "GUILD.TICKET.ARCHIVED"
+ )} Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n`;
+ const dbMember = await client.database.premium.fetchUser(interaction.user.id);
let premium = `You do not have premium! You can't activate premium on any servers.`;
let count = 0;
- const {level, appliesTo} = dbMember ?? {level: 0, appliesTo: []}
+ const { level, appliesTo } = dbMember ?? { level: 0, appliesTo: [] };
if (level === 99) {
premium = `You have Infinite Premium! You have been gifted this by the developers as a thank you. You can give premium to any and all servers you are in.`;
count = 200;
@@ -116,51 +150,53 @@
premium = `You have Premium tier 2! You can give premium to ${3 - appliesTo.length} more server(s).`;
count = 3;
} else if (level === 3) {
- premium = `You have Premium Mod! You can give premium to ${3 - appliesTo.length} more server(s), as well as automatically giving premium to all servers you have a "manage" permission in.`
+ premium = `You have Premium Mod! You can give premium to ${
+ 3 - appliesTo.length
+ } more server(s), as well as automatically giving premium to all servers you have a "manage" permission in.`;
count = 3;
}
if (dbMember?.expiresAt) {
- premium = `**You can't give servers premium anymore because your subscription ended or was cancelled.** To get premium again please subscribe in the Clicks server`
+ premium = `**You can't give servers premium anymore because your subscription ended or was cancelled.** To get premium again please subscribe in the Clicks server`;
count = 0;
}
- if(!interaction.guild) return await dmcallback(interaction, firstDescription, m);
+ if (!interaction.guild) return await dmcallback(interaction, firstDescription, m);
const hasPremium = await client.database.premium.hasPremium(interaction.guild!.id);
- let premiumGuild = ""
+ let premiumGuild = "";
if (hasPremium) {
- premiumGuild = `**This server has premium! It was ${hasPremium[2] === 3 && hasPremium[3] ? `automatically applied by <@${hasPremium[1]}>` : `given by <@${hasPremium[1]}>`}**\n\n`
+ premiumGuild = `**This server has premium! It was ${
+ hasPremium[2] === 3 && hasPremium[3]
+ ? `automatically applied by <@${hasPremium[1]}>`
+ : `given by <@${hasPremium[1]}>`
+ }**\n\n`;
}
- const components: ActionRowBuilder<ButtonBuilder>[] = []
+ const components: ActionRowBuilder<ButtonBuilder>[] = [];
if (level === 0 || dbMember?.expiresAt) {
components.push(
- new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Join Clicks")
.setURL("https://discord.gg/bPaNnxe")
- )
- )
+ )
+ );
} else {
components.push(
- new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setStyle(premiumGuild.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Success)
- .setLabel(premiumGuild.length > 0 ? "This server has premium" : "Activate premium here")
- .setCustomId("premiumActivate")
- .setDisabled(count <= 0 || (hasPremium ? hasPremium[0] : false))
- )
- )
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setStyle(premiumGuild.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Success)
+ .setLabel(premiumGuild.length > 0 ? "This server has premium" : "Activate premium here")
+ .setCustomId("premiumActivate")
+ .setDisabled(count <= 0 || (hasPremium ? hasPremium[0] : false))
+ )
+ );
}
interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Premium")
- .setDescription(
- premiumGuild + premium + firstDescription
- )
+ .setDescription(premiumGuild + premium + firstDescription)
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
.setImage("https://assets.clicks.codes/ads/ads/nucleus-premium.png")
@@ -196,9 +232,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Premium")
- .setDescription(
- `You have activated premium on this server!` + firstDescription
- )
+ .setDescription(`You have activated premium on this server!` + firstDescription)
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
],
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 6ba3445..79a0673 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -1,11 +1,11 @@
-import { LoadingEmbed } from '../../utils/defaults.js';
+import { LoadingEmbed } from "../../utils/defaults.js";
import { ButtonStyle, CommandInteraction } from "discord.js";
import Discord from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
-import getEmojiByName from '../../utils/getEmojiByName.js';
+import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -16,10 +16,10 @@
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
- await interaction.guild?.members.fetch(interaction.member!.user.id)
+ await interaction.guild?.members.fetch(interaction.member!.user.id);
const { renderUser } = client.logger;
const suggestion = interaction.options.get("suggestion")?.value as string;
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
+ await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
const confirmation = await new confirmationMessage(interaction)
.setEmoji("ICONS.OPP.ADD")
.setTitle("Suggest")
@@ -37,22 +37,27 @@
new EmojiEmbed()
.setTitle("Suggestion")
.setDescription(
- `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}\n\n` +
- `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`,
+ `**From:** ${renderUser(
+ interaction.member!.user as Discord.User
+ )}\n**Suggestion:**\n> ${suggestion}\n\n` +
+ `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`
)
.setStatus("Warning")
- ], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
- new Discord.ButtonBuilder()
- .setCustomId("suggestionAccept")
- .setLabel("Accept")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("ICONS.ADD", "id")),
- new Discord.ButtonBuilder()
- .setCustomId("suggestionDeny")
- .setLabel("Delete")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("ICONS.REMOVE", "id"))
- )]
+ ],
+ components: [
+ new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new Discord.ButtonBuilder()
+ .setCustomId("suggestionAccept")
+ .setLabel("Accept")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("ICONS.ADD", "id")),
+ new Discord.ButtonBuilder()
+ .setCustomId("suggestionDeny")
+ .setLabel("Delete")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("ICONS.REMOVE", "id"))
+ )
+ ]
});
await interaction.editReply({
embeds: [
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 69c8980..1b0c6bb 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,5 +1,14 @@
import { LoadingEmbed } from "../utils/defaults.js";
-import Discord, { SlashCommandBuilder, CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuOptionBuilder, SelectMenuOptionBuilder, StringSelectMenuBuilder } from "discord.js";
+import Discord, {
+ SlashCommandBuilder,
+ CommandInteraction,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ StringSelectMenuOptionBuilder,
+ SelectMenuOptionBuilder,
+ StringSelectMenuBuilder
+} from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import createPageIndicator from "../utils/createPageIndicator.js";
@@ -11,7 +20,6 @@
.setName("privacy")
.setDescription("Information and options for you and your server's settings");
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
const pages = [
new Embed()
@@ -48,7 +56,7 @@
new EmojiEmbed()
.setTitle("Link scanning and Transcripts")
.setDescription(
- "Transcripts allow you to store all messages sent in a channel. Transcripts are stored in our database along with the rest of the server's settings but is accessible by anyone with the link, so a leaked link could show all messages sent in the channel.\n"
+ "Transcripts allow you to store all messages sent in a channel. Transcripts are stored in our database along with the rest of the server's settings but is accessible by anyone with the link, so a leaked link could show all messages sent in the channel.\n"
)
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
@@ -59,26 +67,26 @@
].concat(
(interaction.member as Discord.GuildMember).permissions.has("Administrator")
? [
- new Embed()
- .setEmbed(
- new EmojiEmbed()
- .setTitle("Options")
- .setDescription("Below are buttons for controlling this servers privacy settings")
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- )
- .setTitle("Options")
- .setDescription("Options")
- .setPageId(3)
- .setComponents([
- new ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setLabel("Clear all data")
- .setCustomId("clear-all-data")
- .setStyle(ButtonStyle.Danger)
- ])
- ])
- ]
+ new Embed()
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Options")
+ .setDescription("Below are buttons for controlling this servers privacy settings")
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ )
+ .setTitle("Options")
+ .setDescription("Options")
+ .setPageId(3)
+ .setComponents([
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setLabel("Clear all data")
+ .setCustomId("clear-all-data")
+ .setStyle(ButtonStyle.Danger)
+ ])
+ ])
+ ]
: []
);
const m = await interaction.reply({
@@ -86,7 +94,9 @@
fetchReply: true,
ephemeral: true
});
- let page = parseInt(client.preloadPage[interaction.channel!.id] ? client.preloadPage[interaction.channel!.id]?.argument! : "0");
+ let page = parseInt(
+ client.preloadPage[interaction.channel!.id] ? client.preloadPage[interaction.channel!.id]?.argument! : "0"
+ );
let selectPaneOpen = false;
let nextFooter = null;
@@ -146,7 +156,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -206,6 +222,5 @@
});
};
-
export { command };
export { callback };
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 4c88365..815b9e6 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -8,27 +8,26 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("about").setDescription("Shows info about the server");
-
const verificationTypes = {
0: "None - Unrestricted",
1: "Low - Must have a verified email",
2: "Medium - Must be registered for 5 minutes",
3: "High - Must be a member for 10 minutes",
4: "Highest - Must have a verified phone"
-}
+};
const premiumTiers = {
0: "None",
1: "Tier 1",
2: "Tier 2",
3: "Tier 3"
-}
+};
const filterLevels = {
0: "Disabled",
1: "Members without roles",
2: "All members"
-}
+};
const callback = async (interaction: CommandInteraction): Promise<void> => {
const guild = interaction.guild!;
@@ -49,10 +48,10 @@
`${guild.emojis.cache.size}` +
(guild.emojis.cache.size > 1
? `\n> ${guild.emojis.cache
- .first(10)
- .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
- .join(" ")}` +
- (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
+ .first(10)
+ .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
+ .join(" ")}` +
+ (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
: ""),
icon: `[Discord](${guild.iconURL()})`,
"2 factor authentication": `${
diff --git a/src/commands/server/buttons.ts b/src/commands/server/buttons.ts
index 3297616..3ba9c25 100644
--- a/src/commands/server/buttons.ts
+++ b/src/commands/server/buttons.ts
@@ -1,4 +1,19 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType, CommandInteraction, MessageCreateOptions, ModalBuilder, SlashCommandSubcommandBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonStyle,
+ ChannelSelectMenuBuilder,
+ ChannelType,
+ CommandInteraction,
+ MessageCreateOptions,
+ ModalBuilder,
+ SlashCommandSubcommandBuilder,
+ StringSelectMenuBuilder,
+ StringSelectMenuOptionBuilder,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import type Discord from "discord.js";
import { LoadingEmbed } from "../../utils/defaults.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -11,32 +26,31 @@
.setDescription("Create clickable buttons for verifying, role menus etc.");
interface Data {
- buttons: string[],
- title: string | null,
- description: string | null,
- color: number,
- channel: string | null
+ buttons: string[];
+ title: string | null;
+ description: string | null;
+ color: number;
+ channel: string | null;
}
-const colors: Record<string, number> = {
- RED: 0xF27878,
- ORANGE: 0xE5AB71,
- YELLOW: 0xF2D478,
- GREEN: 0x65CC76,
- BLUE: 0x72AEF5,
- PURPLE: 0xA358B2,
- PINK: 0xD46899,
- GRAY: 0x999999,
-}
+const colors: Record<string, number> = {
+ RED: 0xf27878,
+ ORANGE: 0xe5ab71,
+ YELLOW: 0xf2d478,
+ GREEN: 0x65cc76,
+ BLUE: 0x72aef5,
+ PURPLE: 0xa358b2,
+ PINK: 0xd46899,
+ GRAY: 0x999999
+};
const buttonNames: Record<string, string> = {
verifybutton: "Verify",
rolemenu: "Role Menu",
createticket: "Create Ticket"
-}
+};
export const callback = async (interaction: CommandInteraction): Promise<void> => {
-
const m = await interaction.reply({
embeds: LoadingEmbed,
fetchReply: true,
@@ -50,81 +64,76 @@
description: null,
color: colors["RED"]!,
channel: interaction.channelId
- }
+ };
do {
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("edit").setLabel("Edit Embed").setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder()
+ .setCustomId("send")
+ .setLabel("Send")
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(!data.channel)
+ );
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("edit")
- .setLabel("Edit Embed")
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId("send")
- .setLabel("Send")
- .setStyle(ButtonStyle.Primary)
- .setDisabled(!data.channel)
- );
+ const colorSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("color")
+ .setPlaceholder("Select a color")
+ .setMinValues(1)
+ .addOptions(
+ Object.keys(colors).map((color: string) => {
+ return new StringSelectMenuOptionBuilder()
+ .setLabel(lodash.capitalize(color))
+ .setValue(color)
+ .setEmoji(getEmojiByName("COLORS." + color, "id") as APIMessageComponentEmoji)
+ .setDefault(data.color === colors[color]);
+ })
+ )
+ );
- const colorSelect = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("color")
- .setPlaceholder("Select a color")
- .setMinValues(1)
- .addOptions(
- Object.keys(colors).map((color: string) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(lodash.capitalize(color))
- .setValue(color)
- .setEmoji(getEmojiByName("COLORS." + color, "id") as APIMessageComponentEmoji)
- .setDefault(data.color === colors[color])
- }
- )
- )
- );
+ const buttonSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("button")
+ .setPlaceholder("Select buttons to add")
+ .setMinValues(1)
+ .setMaxValues(3)
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Verify")
+ .setValue("verifybutton")
+ .setDescription("Click to get verified in the server")
+ .setDefault(data.buttons.includes("verifybutton")),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Role Menu")
+ .setValue("rolemenu")
+ .setDescription("Click to customize your roles")
+ .setDefault(data.buttons.includes("rolemenu")),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Ticket")
+ .setValue("createticket")
+ .setDescription("Click to create a support ticket")
+ .setDefault(data.buttons.includes("createticket"))
+ )
+ );
- const buttonSelect = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("button")
- .setPlaceholder("Select buttons to add")
- .setMinValues(1)
- .setMaxValues(3)
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Verify")
- .setValue("verifybutton")
- .setDescription("Click to get verified in the server")
- .setDefault(data.buttons.includes("verifybutton")),
- new StringSelectMenuOptionBuilder()
- .setLabel("Role Menu")
- .setValue("rolemenu")
- .setDescription("Click to customize your roles")
- .setDefault(data.buttons.includes("rolemenu")),
- new StringSelectMenuOptionBuilder()
- .setLabel("Ticket")
- .setValue("createticket")
- .setDescription("Click to create a support ticket")
- .setDefault(data.buttons.includes("createticket"))
- )
- )
-
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel")
- .setChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement, ChannelType.PublicThread, ChannelType.AnnouncementThread)
- )
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select a channel")
+ .setChannelTypes(
+ ChannelType.GuildText,
+ ChannelType.GuildAnnouncement,
+ ChannelType.PublicThread,
+ ChannelType.AnnouncementThread
+ )
+ );
let channelName = interaction.guild!.channels.cache.get(data.channel!)?.name;
if (data.channel === interaction.channelId) channelName = "this channel";
const embed = new EmojiEmbed()
.setTitle(data.title ?? "No title set")
.setDescription(data.description ?? "*No description set*")
.setColor(data.color)
- .setFooter({text: `Click the button below to edit the embed | The embed will be sent in ${channelName}`});
-
+ .setFooter({ text: `Click the button below to edit the embed | The embed will be sent in ${channelName}` });
await interaction.editReply({
embeds: [embed],
@@ -133,16 +142,19 @@
let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction | Discord.StringSelectMenuInteraction;
try {
- i = await interaction.channel!.awaitMessageComponent({
+ i = (await interaction.channel!.awaitMessageComponent({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id,
time: 300000
- }) as Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction | Discord.StringSelectMenuInteraction;
+ })) as
+ | Discord.ButtonInteraction
+ | Discord.ChannelSelectMenuInteraction
+ | Discord.StringSelectMenuInteraction;
} catch (e) {
closed = true;
break;
}
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "edit": {
await i.showModal(
new ModalBuilder()
@@ -189,43 +201,56 @@
});
let out: Discord.ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as Discord.ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(
+ m,
+ interaction.user
+ )) as Discord.ModalSubmitInteraction | null;
} catch (e) {
closed = true;
continue;
}
- if (!out || out.isButton()) continue
- data.title = out.fields.getTextInputValue("title").length === 0 ? null : out.fields.getTextInputValue("title");
- data.description = out.fields.getTextInputValue("description").length === 0 ? null : out.fields.getTextInputValue("description");
+ if (!out || out.isButton()) continue;
+ data.title =
+ out.fields.getTextInputValue("title").length === 0
+ ? null
+ : out.fields.getTextInputValue("title");
+ data.description =
+ out.fields.getTextInputValue("description").length === 0
+ ? null
+ : out.fields.getTextInputValue("description");
break;
}
case "send": {
await i.deferUpdate();
const channel = interaction.guild!.channels.cache.get(data.channel!) as Discord.TextChannel;
const components = new ActionRowBuilder<ButtonBuilder>();
- for(const button of data.buttons) {
+ for (const button of data.buttons) {
components.addComponents(
new ButtonBuilder()
- .setCustomId(button)
- .setLabel(buttonNames[button]!)
- .setStyle(ButtonStyle.Primary)
- );
- }
- const messageData: MessageCreateOptions = {components: [components]}
+ .setCustomId(button)
+ .setLabel(buttonNames[button]!)
+ .setStyle(ButtonStyle.Primary)
+ );
+ }
+ const messageData: MessageCreateOptions = { components: [components] };
if (data.title || data.description) {
- const e = new EmojiEmbed()
- if(data.title) e.setTitle(data.title);
- if(data.description) e.setDescription(data.description);
- if(data.color) e.setColor(data.color);
+ const e = new EmojiEmbed();
+ if (data.title) e.setTitle(data.title);
+ if (data.description) e.setDescription(data.description);
+ if (data.color) e.setColor(data.color);
messageData.embeds = [e];
}
await channel.send(messageData);
break;
}
}
- } else if(i.isStringSelectMenu()) {
- try {await i.deferUpdate();} catch (err) {console.log(err)}
- switch(i.customId) {
+ } else if (i.isStringSelectMenu()) {
+ try {
+ await i.deferUpdate();
+ } catch (err) {
+ console.log(err);
+ }
+ switch (i.customId) {
case "color": {
data.color = colors[i.values[0]!]!;
break;
@@ -239,10 +264,9 @@
await i.deferUpdate();
data.channel = i.values[0]!;
}
-
} while (!closed);
await interaction.deleteReply();
-}
+};
export const check = (interaction: CommandInteraction, _partial: boolean = false) => {
const member = interaction.member as Discord.GuildMember;
diff --git a/src/commands/settings/_meta.ts b/src/commands/settings/_meta.ts
index 666dbf4..1acc511 100644
--- a/src/commands/settings/_meta.ts
+++ b/src/commands/settings/_meta.ts
@@ -3,9 +3,6 @@
const name = "settings";
const description = "Change bot settings";
+const subcommand = await command(name, description, "settings", undefined, undefined, undefined, ["ManageGuild"]);
-const subcommand = await command(name, description, "settings", undefined, undefined, undefined, [
- "ManageGuild"
-])
-
-export { name, description, subcommand as command};
+export { name, description, subcommand as command };
diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts
index ff9e0b2..9d59520 100644
--- a/src/commands/settings/automod.ts
+++ b/src/commands/settings/automod.ts
@@ -1,5 +1,6 @@
import type Discord from "discord.js";
-import { ActionRowBuilder,
+import {
+ ActionRowBuilder,
AnySelectMenuInteraction,
APIMessageComponentEmoji,
ButtonBuilder,
@@ -28,49 +29,77 @@
import { modalInteractionCollector } from "../../utils/dualCollector.js";
import listToAndMore from "../../utils/listToAndMore.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("automod").setDescription("Setting for automatic moderation features");
+const emojiFromBoolean = (bool: boolean, id?: string) =>
+ bool ? getEmojiByName("CONTROL.TICK", id) : getEmojiByName("CONTROL.CROSS", id);
-const emojiFromBoolean = (bool: boolean, id?: string) => bool ? getEmojiByName("CONTROL.TICK", id) : getEmojiByName("CONTROL.CROSS", id);
-
-const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message, ids: string[], type: "member" | "role" | "channel", title: string): Promise<string[]> => {
-
- const back = new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setCustomId("back").setLabel("Back").setStyle(ButtonStyle.Secondary).setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji));
+const toSelectMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ ids: string[],
+ type: "member" | "role" | "channel",
+ title: string
+): Promise<string[]> => {
+ const back = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
let closed;
do {
- let render: string[] = []
+ let render: string[] = [];
let mapped: string[] = [];
let menu: UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder;
- switch(type) {
+ switch (type) {
case "member": {
menu = new UserSelectMenuBuilder().setCustomId("user").setPlaceholder("Select users").setMaxValues(25);
- mapped = await Promise.all(ids.map(async (id) => { return (await client.users.fetch(id).then(user => user.tag)) || "Unknown User" }));
- render = ids.map(id => client.logger.renderUser(id))
+ mapped = await Promise.all(
+ ids.map(async (id) => {
+ return (await client.users.fetch(id).then((user) => user.tag)) || "Unknown User";
+ })
+ );
+ render = ids.map((id) => client.logger.renderUser(id));
break;
}
case "role": {
menu = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select roles").setMaxValues(25);
- mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name ?? "Unknown Role"))}));
- render = ids.map(id => client.logger.renderRole(id, interaction.guild!))
+ mapped = await Promise.all(
+ ids.map(async (id) => {
+ return await interaction.guild!.roles.fetch(id).then((role) => role?.name ?? "Unknown Role");
+ })
+ );
+ render = ids.map((id) => client.logger.renderRole(id, interaction.guild!));
break;
}
case "channel": {
- menu = new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select channels").setMaxValues(25);
- mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name ?? "Unknown Role")) }));
- render = ids.map(id => client.logger.renderChannel(id))
+ menu = new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select channels")
+ .setMaxValues(25);
+ mapped = await Promise.all(
+ ids.map(async (id) => {
+ return await interaction
+ .guild!.channels.fetch(id)
+ .then((channel) => channel?.name ?? "Unknown Role");
+ })
+ );
+ render = ids.map((id) => client.logger.renderChannel(id));
break;
}
}
- const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("remove")
- .setPlaceholder("Remove")
- .addOptions(mapped.map((name, i) => new StringSelectMenuOptionBuilder().setLabel(name).setValue(ids[i]!)))
- .setDisabled(ids.length === 0)
- );
+ const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("remove")
+ .setPlaceholder("Remove")
+ .addOptions(
+ mapped.map((name, i) => new StringSelectMenuOptionBuilder().setLabel(name).setValue(ids[i]!))
+ )
+ .setDisabled(ids.length === 0)
+ );
const embed = new EmojiEmbed()
.setTitle(title)
@@ -78,96 +107,100 @@
.setDescription(`Select ${type}s:\n\nCurrent:\n` + (render.length > 0 ? render.join("\n") : "None"))
.setStatus("Success");
const components: ActionRowBuilder<
- StringSelectMenuBuilder |
- ButtonBuilder |
- ChannelSelectMenuBuilder |
- UserSelectMenuBuilder |
- RoleSelectMenuBuilder
- >[] = [new ActionRowBuilder<typeof menu>().addComponents(menu)]
- if(ids.length > 0) components.push(removeOptions);
+ | StringSelectMenuBuilder
+ | ButtonBuilder
+ | ChannelSelectMenuBuilder
+ | UserSelectMenuBuilder
+ | RoleSelectMenuBuilder
+ >[] = [new ActionRowBuilder<typeof menu>().addComponents(menu)];
+ if (ids.length > 0) components.push(removeOptions);
components.push(back);
- await interaction.editReply({embeds: [embed], components: components})
+ await interaction.editReply({ embeds: [embed], components: components });
let i: AnySelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({filter: i => i.user.id === interaction.user.id, time: 300000});
- } catch(e) {
+ i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 });
+ } catch (e) {
closed = true;
continue;
}
- if(i.isButton()) {
+ if (i.isButton()) {
await i.deferUpdate();
- if(i.customId === "back") {
+ if (i.customId === "back") {
closed = true;
break;
}
- } else if(i.isStringSelectMenu()) {
+ } else if (i.isStringSelectMenu()) {
await i.deferUpdate();
- if(i.customId === "remove") {
- ids = ids.filter(id => id !== (i as StringSelectMenuInteraction).values[0]);
- if(ids.length === 0) {
+ if (i.customId === "remove") {
+ ids = ids.filter((id) => id !== (i as StringSelectMenuInteraction).values[0]);
+ if (ids.length === 0) {
menu.data.disabled = true;
}
}
} else {
await i.deferUpdate();
- if(i.customId === "user") {
+ if (i.customId === "user") {
ids = ids.concat((i as UserSelectMenuInteraction).values);
- } else if(i.customId === "role") {
+ } else if (i.customId === "role") {
ids = ids.concat((i as RoleSelectMenuInteraction).values);
- } else if(i.customId === "channel") {
+ } else if (i.customId === "channel") {
ids = ids.concat((i as ChannelSelectMenuInteraction).values);
}
}
-
- } while(!closed)
+ } while (!closed);
return ids;
-}
+};
-const imageMenu = async (interaction: StringSelectMenuInteraction, m: Message, current: {
- NSFW: boolean,
- size: boolean
-}): Promise<{NSFW: boolean, size: boolean}> => {
+const imageMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ current: {
+ NSFW: boolean;
+ size: boolean;
+ }
+): Promise<{ NSFW: boolean; size: boolean }> => {
let closed = false;
do {
- const options = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("nsfw")
- .setLabel("NSFW")
- .setStyle(current.NSFW ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.NSFW, "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("size")
- .setLabel("Size")
- .setStyle(current.size ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.size, "id") as APIMessageComponentEmoji)
- )
+ const options = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("nsfw")
+ .setLabel("NSFW")
+ .setStyle(current.NSFW ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.NSFW, "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("size")
+ .setLabel("Size")
+ .setStyle(current.size ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.size, "id") as APIMessageComponentEmoji)
+ );
const embed = new EmojiEmbed()
.setTitle("Image Settings")
.setDescription(
- `${emojiFromBoolean(current.NSFW)} **NSFW**\n` +
- `${emojiFromBoolean(current.size)} **Size**\n`
- )
+ `${emojiFromBoolean(current.NSFW)} **NSFW**\n` + `${emojiFromBoolean(current.size)} **Size**\n`
+ );
- await interaction.editReply({embeds: [embed], components: [options]});
+ await interaction.editReply({ embeds: [embed], components: [options] });
let i: ButtonInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction;
} catch (e) {
return current;
}
await i.deferUpdate();
- switch(i.customId) {
+ switch (i.customId) {
case "back": {
closed = true;
break;
@@ -181,87 +214,106 @@
break;
}
}
- } while(!closed);
+ } while (!closed);
return current;
-}
+};
-const wordMenu = async (interaction: StringSelectMenuInteraction, m: Message, current: {
- enabled: boolean,
- words: {strict: string[], loose: string[]},
- allowed: {users: string[], roles: string[], channels: string[]}
-}): Promise<{
- enabled: boolean,
- words: {strict: string[], loose: string[]},
- allowed: {users: string[], roles: string[], channels: string[]}
+const wordMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ current: {
+ enabled: boolean;
+ words: { strict: string[]; loose: string[] };
+ allowed: { users: string[]; roles: string[]; channels: string[] };
+ }
+): Promise<{
+ enabled: boolean;
+ words: { strict: string[]; loose: string[] };
+ allowed: { users: string[]; roles: string[]; channels: string[] };
}> => {
let closed = false;
do {
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("enabled")
- .setLabel("Enabled")
- .setStyle(current.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.enabled, "id") as APIMessageComponentEmoji),
- );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("enabled")
+ .setLabel("Enabled")
+ .setStyle(current.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.enabled, "id") as APIMessageComponentEmoji)
+ );
- const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("edit")
- .setPlaceholder("Edit... ")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Words")
- .setDescription("Edit your list of words to filter")
- .setValue("words"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Allowed Users")
- .setDescription("Users who will be unaffected by the word filter")
- .setValue("allowedUsers"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Allowed Roles")
- .setDescription("Roles that will be unaffected by the word filter")
- .setValue("allowedRoles"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Allowed Channels")
- .setDescription("Channels where the word filter will not apply")
- .setValue("allowedChannels")
- )
- .setDisabled(!current.enabled)
- );
+ const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("edit")
+ .setPlaceholder("Edit... ")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Words")
+ .setDescription("Edit your list of words to filter")
+ .setValue("words"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Allowed Users")
+ .setDescription("Users who will be unaffected by the word filter")
+ .setValue("allowedUsers"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Allowed Roles")
+ .setDescription("Roles that will be unaffected by the word filter")
+ .setValue("allowedRoles"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Allowed Channels")
+ .setDescription("Channels where the word filter will not apply")
+ .setValue("allowedChannels")
+ )
+ .setDisabled(!current.enabled)
+ );
const embed = new EmojiEmbed()
.setTitle("Word Filters")
.setDescription(
`${emojiFromBoolean(current.enabled)} **Enabled**\n` +
- `**Strict Words:** ${listToAndMore(current.words.strict, 5)}\n` +
- `**Loose Words:** ${listToAndMore(current.words.loose, 5)}\n\n` +
- `**Users:** ` + listToAndMore(current.allowed.users.map(user => `<@${user}>`), 5) + `\n` +
- `**Roles:** ` + listToAndMore(current.allowed.roles.map(role => `<@&${role}>`), 5) + `\n` +
- `**Channels:** ` + listToAndMore(current.allowed.channels.map(channel => `<#${channel}>`), 5)
+ `**Strict Words:** ${listToAndMore(current.words.strict, 5)}\n` +
+ `**Loose Words:** ${listToAndMore(current.words.loose, 5)}\n\n` +
+ `**Users:** ` +
+ listToAndMore(
+ current.allowed.users.map((user) => `<@${user}>`),
+ 5
+ ) +
+ `\n` +
+ `**Roles:** ` +
+ listToAndMore(
+ current.allowed.roles.map((role) => `<@&${role}>`),
+ 5
+ ) +
+ `\n` +
+ `**Channels:** ` +
+ listToAndMore(
+ current.allowed.channels.map((channel) => `<#${channel}>`),
+ 5
+ )
)
.setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
+ .setEmoji("GUILD.SETTINGS.GREEN");
- await interaction.editReply({embeds: [embed], components: [selectMenu, buttons]});
+ await interaction.editReply({ embeds: [embed], components: [selectMenu, buttons] });
let i: ButtonInteraction | StringSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
closed = true;
break;
}
- if(i.isButton()) {
+ if (i.isButton()) {
await i.deferUpdate();
- switch(i.customId) {
+ switch (i.customId) {
case "back": {
closed = true;
break;
@@ -272,44 +324,53 @@
}
}
} else {
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "words": {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Word Filter")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
- ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle(ButtonStyle.Primary)
- .setCustomId("back")
- )]})
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Word Filter")
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
+ .setStatus("Success")
+ .setEmoji("GUILD.SETTINGS.GREEN")
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Primary)
+ .setCustomId("back")
+ )
+ ]
+ });
const modal = new ModalBuilder()
.setTitle("Word Filter")
.setCustomId("wordFilter")
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setCustomId("wordStrict")
- .setLabel("Strict Words")
- .setPlaceholder("Matches anywhere in the message, including surrounded by other characters")
- .setValue(current.words.strict.join(", "))
- .setStyle(TextInputStyle.Paragraph)
- .setRequired(false)
- ),
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setCustomId("wordLoose")
- .setLabel("Loose Words")
- .setPlaceholder("Matches only if the word is by itself, surrounded by spaces or punctuation")
- .setValue(current.words.loose.join(", "))
- .setStyle(TextInputStyle.Paragraph)
- .setRequired(false)
- )
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("wordStrict")
+ .setLabel("Strict Words")
+ .setPlaceholder(
+ "Matches anywhere in the message, including surrounded by other characters"
+ )
+ .setValue(current.words.strict.join(", "))
+ .setStyle(TextInputStyle.Paragraph)
+ .setRequired(false)
+ ),
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("wordLoose")
+ .setLabel("Loose Words")
+ .setPlaceholder(
+ "Matches only if the word is by itself, surrounded by spaces or punctuation"
+ )
+ .setValue(current.words.loose.join(", "))
+ .setStyle(TextInputStyle.Paragraph)
+ .setRequired(false)
+ )
+ );
await i.showModal(modal);
let out;
@@ -319,103 +380,146 @@
break;
}
if (!out) break;
- if(out.isButton()) break;
- current.words.strict = out.fields.getTextInputValue("wordStrict")
- .split(",").map(s => s.trim()).filter(s => s.length > 0);
- current.words.loose = out.fields.getTextInputValue("wordLoose")
- .split(",").map(s => s.trim()).filter(s => s.length > 0);
+ if (out.isButton()) break;
+ current.words.strict = out.fields
+ .getTextInputValue("wordStrict")
+ .split(",")
+ .map((s) => s.trim())
+ .filter((s) => s.length > 0);
+ current.words.loose = out.fields
+ .getTextInputValue("wordLoose")
+ .split(",")
+ .map((s) => s.trim())
+ .filter((s) => s.length > 0);
break;
}
case "allowedUsers": {
await i.deferUpdate();
- current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter");
+ current.allowed.users = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.users,
+ "member",
+ "Word Filter"
+ );
break;
}
case "allowedRoles": {
await i.deferUpdate();
- current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter");
+ current.allowed.roles = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.roles,
+ "role",
+ "Word Filter"
+ );
break;
}
case "allowedChannels": {
await i.deferUpdate();
- current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter");
+ current.allowed.channels = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.channels,
+ "channel",
+ "Word Filter"
+ );
break;
}
}
}
- } while(!closed);
+ } while (!closed);
return current;
-}
+};
-const inviteMenu = async (interaction: StringSelectMenuInteraction, m: Message, current: {
- enabled: boolean,
- allowed: {users: string[], roles: string[], channels: string[]}
-}): Promise<{
- enabled: boolean,
- allowed: {users: string[], roles: string[], channels: string[]}
+const inviteMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ current: {
+ enabled: boolean;
+ allowed: { users: string[]; roles: string[]; channels: string[] };
+ }
+): Promise<{
+ enabled: boolean;
+ allowed: { users: string[]; roles: string[]; channels: string[] };
}> => {
-
let closed = false;
do {
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("enabled")
- .setLabel(current.enabled ? "Enabled" : "Disabled")
- .setStyle(current.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.enabled, "id") as APIMessageComponentEmoji)
- );
- const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("toEdit")
- .setPlaceholder("Edit your allow list")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Users")
- .setDescription("Users that are allowed to send invites")
- .setValue("users"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Roles")
- .setDescription("Roles that are allowed to send invites")
- .setValue("roles"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Channels")
- .setDescription("Channels that anyone is allowed to send invites in")
- .setValue("channels")
- ).setDisabled(!current.enabled)
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("enabled")
+ .setLabel(current.enabled ? "Enabled" : "Disabled")
+ .setStyle(current.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.enabled, "id") as APIMessageComponentEmoji)
+ );
+ const menu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("toEdit")
+ .setPlaceholder("Edit your allow list")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Users")
+ .setDescription("Users that are allowed to send invites")
+ .setValue("users"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Roles")
+ .setDescription("Roles that are allowed to send invites")
+ .setValue("roles"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Channels")
+ .setDescription("Channels that anyone is allowed to send invites in")
+ .setValue("channels")
)
+ .setDisabled(!current.enabled)
+ );
const embed = new EmojiEmbed()
.setTitle("Invite Settings")
.setDescription(
- "Automatically deletes invites sent by users (outside of staff members and self promotion channels)" + `\n\n` +
- `${emojiFromBoolean(current.enabled)} **${current.enabled ? "Enabled" : "Disabled"}**\n\n` +
- `**Users:** ` + listToAndMore(current.allowed.users.map(user => `<@${user}>`), 5) + `\n` +
- `**Roles:** ` + listToAndMore(current.allowed.roles.map(role => `<@&${role}>`), 5) + `\n` +
- `**Channels:** ` + listToAndMore(current.allowed.channels.map(channel => `<#${channel}>`), 5)
+ "Automatically deletes invites sent by users (outside of staff members and self promotion channels)" +
+ `\n\n` +
+ `${emojiFromBoolean(current.enabled)} **${current.enabled ? "Enabled" : "Disabled"}**\n\n` +
+ `**Users:** ` +
+ listToAndMore(
+ current.allowed.users.map((user) => `<@${user}>`),
+ 5
+ ) +
+ `\n` +
+ `**Roles:** ` +
+ listToAndMore(
+ current.allowed.roles.map((role) => `<@&${role}>`),
+ 5
+ ) +
+ `\n` +
+ `**Channels:** ` +
+ listToAndMore(
+ current.allowed.channels.map((channel) => `<#${channel}>`),
+ 5
+ )
)
.setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
+ .setEmoji("GUILD.SETTINGS.GREEN");
-
- await interaction.editReply({embeds: [embed], components: [menu, buttons]});
+ await interaction.editReply({ embeds: [embed], components: [menu, buttons] });
let i: ButtonInteraction | StringSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
return current;
}
- if(i.isButton()) {
+ if (i.isButton()) {
await i.deferUpdate();
- switch(i.customId) {
+ switch (i.customId) {
case "back": {
closed = true;
break;
@@ -427,135 +531,181 @@
}
} else {
await i.deferUpdate();
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings");
+ current.allowed.users = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.users,
+ "member",
+ "Invite Settings"
+ );
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings");
+ current.allowed.roles = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.roles,
+ "role",
+ "Invite Settings"
+ );
break;
}
case "channels": {
- current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings");
+ current.allowed.channels = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.channels,
+ "channel",
+ "Invite Settings"
+ );
break;
}
}
}
-
- } while(!closed);
+ } while (!closed);
return current;
-}
+};
-const mentionMenu = async (interaction: StringSelectMenuInteraction, m: Message, current: {
- mass: number,
- everyone: boolean,
- roles: boolean,
- allowed: {
- roles: string[],
- rolesToMention: string[],
- users: string[],
- channels: string[]
+const mentionMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ current: {
+ mass: number;
+ everyone: boolean;
+ roles: boolean;
+ allowed: {
+ roles: string[];
+ rolesToMention: string[];
+ users: string[];
+ channels: string[];
+ };
}
-}): Promise<{
- mass: number,
- everyone: boolean,
- roles: boolean,
+): Promise<{
+ mass: number;
+ everyone: boolean;
+ roles: boolean;
allowed: {
- roles: string[],
- rolesToMention: string[],
- users: string[],
- channels: string[]
- }
+ roles: string[];
+ rolesToMention: string[];
+ users: string[];
+ channels: string[];
+ };
}> => {
let closed = false;
do {
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("everyone")
+ .setLabel(current.everyone ? "Everyone" : "No one")
+ .setStyle(current.everyone ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.everyone, "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("roles")
+ .setLabel(current.roles ? "Roles" : "No roles")
+ .setStyle(current.roles ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(emojiFromBoolean(current.roles, "id") as APIMessageComponentEmoji)
+ );
+ const menu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("toEdit")
+ .setPlaceholder("Edit mention settings")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Mass Mention Amount")
+ .setDescription("The amount of mentions before the bot will delete the message")
+ .setValue("mass"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Roles")
+ .setDescription("Roles that are able to be mentioned")
+ .setValue("roles")
+ )
+ );
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("everyone")
- .setLabel(current.everyone ? "Everyone" : "No one")
- .setStyle(current.everyone ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.everyone, "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("roles")
- .setLabel(current.roles ? "Roles" : "No roles")
- .setStyle(current.roles ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(emojiFromBoolean(current.roles, "id") as APIMessageComponentEmoji)
- );
- const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("toEdit")
- .setPlaceholder("Edit mention settings")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Mass Mention Amount")
- .setDescription("The amount of mentions before the bot will delete the message")
- .setValue("mass"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Roles")
- .setDescription("Roles that are able to be mentioned")
- .setValue("roles"),
- )
- )
-
- const allowedMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("allowed")
- .setPlaceholder("Edit exceptions")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Users")
- .setDescription("Users that are unaffected by the mention filter")
- .setValue("users"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Roles")
- .setDescription("Roles that are unaffected by the mention filter")
- .setValue("roles"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Channels")
- .setDescription("Channels where anyone is unaffected by the mention filter")
- .setValue("channels")
- )
- )
+ const allowedMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("allowed")
+ .setPlaceholder("Edit exceptions")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Users")
+ .setDescription("Users that are unaffected by the mention filter")
+ .setValue("users"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Roles")
+ .setDescription("Roles that are unaffected by the mention filter")
+ .setValue("roles"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Channels")
+ .setDescription("Channels where anyone is unaffected by the mention filter")
+ .setValue("channels")
+ )
+ );
const embed = new EmojiEmbed()
.setTitle("Mention Settings")
.setDescription(
`Log when members mention:\n` +
- `${emojiFromBoolean(true)} **${current.mass}+ members** in one message\n` +
- `${emojiFromBoolean(current.everyone)} **Everyone**\n` +
- `${emojiFromBoolean(current.roles)} **Roles**\n` +
- (current.allowed.rolesToMention.length > 0 ? `> *Except for ${listToAndMore(current.allowed.rolesToMention.map(r => `<@&${r}>`), 3)}*\n` : "") +
- "\n" +
- `Except if...\n` +
- `> ${current.allowed.users.length > 0 ? `Member is: ${listToAndMore(current.allowed.users.map(u => `<@${u}>`), 3)}\n` : ""}` +
- `> ${current.allowed.roles.length > 0 ? `Member has role: ${listToAndMore(current.allowed.roles.map(r => `<@&${r}>`), 3)}\n` : ""}` +
- `> ${current.allowed.channels.length > 0 ? `In channel: ${listToAndMore(current.allowed.channels.map(c => `<#${c}>`), 3)}\n` : ""}`
+ `${emojiFromBoolean(true)} **${current.mass}+ members** in one message\n` +
+ `${emojiFromBoolean(current.everyone)} **Everyone**\n` +
+ `${emojiFromBoolean(current.roles)} **Roles**\n` +
+ (current.allowed.rolesToMention.length > 0
+ ? `> *Except for ${listToAndMore(
+ current.allowed.rolesToMention.map((r) => `<@&${r}>`),
+ 3
+ )}*\n`
+ : "") +
+ "\n" +
+ `Except if...\n` +
+ `> ${
+ current.allowed.users.length > 0
+ ? `Member is: ${listToAndMore(
+ current.allowed.users.map((u) => `<@${u}>`),
+ 3
+ )}\n`
+ : ""
+ }` +
+ `> ${
+ current.allowed.roles.length > 0
+ ? `Member has role: ${listToAndMore(
+ current.allowed.roles.map((r) => `<@&${r}>`),
+ 3
+ )}\n`
+ : ""
+ }` +
+ `> ${
+ current.allowed.channels.length > 0
+ ? `In channel: ${listToAndMore(
+ current.allowed.channels.map((c) => `<#${c}>`),
+ 3
+ )}\n`
+ : ""
+ }`
)
.setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
+ .setEmoji("GUILD.SETTINGS.GREEN");
- await interaction.editReply({embeds: [embed], components: [menu, allowedMenu, buttons]});
+ await interaction.editReply({ embeds: [embed], components: [menu, allowedMenu, buttons] });
let i: ButtonInteraction | StringSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
closed = true;
break;
}
- if(i.isButton()) {
+ if (i.isButton()) {
await i.deferUpdate();
switch (i.customId) {
case "back": {
@@ -576,31 +726,37 @@
case "toEdit": {
switch (i.values[0]) {
case "mass": {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Word Filter")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
- ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle(ButtonStyle.Primary)
- .setCustomId("back")
- )]})
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Word Filter")
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
+ .setStatus("Success")
+ .setEmoji("GUILD.SETTINGS.GREEN")
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Primary)
+ .setCustomId("back")
+ )
+ ]
+ });
const modal = new ModalBuilder()
.setTitle("Mass Mention Amount")
.setCustomId("mass")
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setCustomId("mass")
- .setPlaceholder("Amount")
- .setMinLength(1)
- .setMaxLength(3)
- .setStyle(TextInputStyle.Short)
- )
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("mass")
+ .setPlaceholder("Amount")
+ .setMinLength(1)
+ .setMaxLength(3)
+ .setStyle(TextInputStyle.Short)
+ )
+ );
await i.showModal(modal);
let out;
try {
@@ -609,13 +765,19 @@
break;
}
if (!out) break;
- if(out.isButton()) break;
+ if (out.isButton()) break;
current.mass = parseInt(out.fields.getTextInputValue("mass"));
break;
}
case "roles": {
await i.deferUpdate();
- current.allowed.rolesToMention = await toSelectMenu(interaction, m, current.allowed.rolesToMention, "role", "Mention Settings");
+ current.allowed.rolesToMention = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.rolesToMention,
+ "role",
+ "Mention Settings"
+ );
break;
}
}
@@ -625,15 +787,33 @@
await i.deferUpdate();
switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings");
+ current.allowed.users = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.users,
+ "member",
+ "Mention Settings"
+ );
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings");
+ current.allowed.roles = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.roles,
+ "role",
+ "Mention Settings"
+ );
break;
}
case "channels": {
- current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Mention Settings");
+ current.allowed.channels = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.channels,
+ "channel",
+ "Mention Settings"
+ );
break;
}
}
@@ -641,85 +821,91 @@
}
}
}
+ } while (!closed);
+ return current;
+};
- } while(!closed);
- return current
-}
-
-const cleanMenu = async (interaction: StringSelectMenuInteraction, m: Message, current?: {
- channels?: string[],
- allowed?: {
- roles: string[],
- users: string[]
+const cleanMenu = async (
+ interaction: StringSelectMenuInteraction,
+ m: Message,
+ current?: {
+ channels?: string[];
+ allowed?: {
+ roles: string[];
+ users: string[];
+ };
}
-}): Promise<{
- channels: string[],
+): Promise<{
+ channels: string[];
allowed: {
- roles: string[],
- users: string[]
- }
+ roles: string[];
+ users: string[];
+ };
}> => {
let closed = false;
- if(!current) current = {channels: [], allowed: {roles: [], users: []}};
- if(!current.channels) current.channels = [];
- if(!current.allowed) current.allowed = {roles: [], users: []};
+ if (!current) current = { channels: [], allowed: { roles: [], users: [] } };
+ if (!current.channels) current.channels = [];
+ if (!current.allowed) current.allowed = { roles: [], users: [] };
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("toAdd")
- .setPlaceholder("Select a channel")
- )
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder().setCustomId("toAdd").setPlaceholder("Select a channel")
+ );
- const allowedMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("allowed")
- .setPlaceholder("Edit exceptions")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Users")
- .setDescription("Users that are unaffected by the mention filter")
- .setValue("users"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Roles")
- .setDescription("Roles that are unaffected by the mention filter")
- .setValue("roles")
- )
- )
+ const allowedMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("allowed")
+ .setPlaceholder("Edit exceptions")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Users")
+ .setDescription("Users that are unaffected by the mention filter")
+ .setValue("users"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Roles")
+ .setDescription("Roles that are unaffected by the mention filter")
+ .setValue("roles")
+ )
+ );
do {
-
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- )
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ );
const embed = new EmojiEmbed()
.setTitle("Clean Settings")
.setEmoji("GUILD.SETTINGS.GREEN")
.setDescription(
`Current clean channels:\n\n` +
- `${current.channels.length > 0 ? listToAndMore(current.channels.map(c => `<#${c}>`), 10) : "None"}\n\n`
+ `${
+ current.channels.length > 0
+ ? listToAndMore(
+ current.channels.map((c) => `<#${c}>`),
+ 10
+ )
+ : "None"
+ }\n\n`
)
- .setStatus("Success")
+ .setStatus("Success");
-
- await interaction.editReply({embeds: [embed], components: [channelMenu, allowedMenu, buttons]});
+ await interaction.editReply({ embeds: [embed], components: [channelMenu, allowedMenu, buttons] });
let i: ButtonInteraction | ChannelSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction | ChannelSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction | ChannelSelectMenuInteraction;
} catch (e) {
closed = true;
break;
}
await i.deferUpdate();
- if(i.isButton()) {
+ if (i.isButton()) {
switch (i.customId) {
case "back": {
closed = true;
@@ -733,24 +919,28 @@
.setTitle("Clean Settings")
.setDescription(`Editing <#${i.values[0]}>`)
.setEmoji("GUILD.SETTINGS.GREEN")
- .setStatus("Success")
- const channelButtons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
- new ButtonBuilder()
- .setCustomId("switch")
- .setLabel(current.channels.includes(i.values[0]!) ? "Remove" : "Add")
- .setStyle(current.channels.includes(i.values[0]!) ? ButtonStyle.Danger : ButtonStyle.Success)
- )
+ .setStatus("Success");
+ const channelButtons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
+ new ButtonBuilder()
+ .setCustomId("switch")
+ .setLabel(current.channels.includes(i.values[0]!) ? "Remove" : "Add")
+ .setStyle(
+ current.channels.includes(i.values[0]!) ? ButtonStyle.Danger : ButtonStyle.Success
+ )
+ );
- await i.editReply({embeds: [channelEmbed], components: [channelButtons]});
+ await i.editReply({ embeds: [channelEmbed], components: [channelButtons] });
let j: ButtonInteraction;
try {
- j = await m.awaitMessageComponent({filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id, time: 300000}) as ButtonInteraction;
+ j = (await m.awaitMessageComponent({
+ filter: (i) => interaction.user.id === i.user.id && i.message.id === m.id,
+ time: 300000
+ })) as ButtonInteraction;
} catch (e) {
closed = true;
break;
@@ -761,7 +951,7 @@
break;
}
case "switch": {
- if(current.channels.includes(i.values[0]!)) {
+ if (current.channels.includes(i.values[0]!)) {
current.channels.splice(current.channels.indexOf(i.values[0]!), 1);
} else {
current.channels.push(i.values[0]!);
@@ -773,11 +963,23 @@
case "allowed": {
switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings");
+ current.allowed.users = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.users,
+ "member",
+ "Mention Settings"
+ );
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings");
+ current.allowed.roles = await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.roles,
+ "role",
+ "Mention Settings"
+ );
break;
}
}
@@ -785,98 +987,94 @@
}
}
}
-
- } while(!closed);
+ } while (!closed);
return current as {
- channels: string[],
+ channels: string[];
allowed: {
- roles: string[],
- users: string[]
- }
+ roles: string[];
+ users: string[];
+ };
};
-
-}
+};
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+ const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
const config = (await client.database.guilds.read(interaction.guild.id)).filters;
let closed = false;
- const button = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- )
+ const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("save").setLabel("Save").setStyle(ButtonStyle.Success)
+ );
do {
-
- const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("filter")
- .setPlaceholder("Select a filter to edit")
- .addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel("Invites")
- .setDescription("Automatically delete messages containing server invites")
- .setValue("invites"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Mentions")
- .setDescription("Deletes messages with excessive mentions")
- .setValue("mentions"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Words")
- .setDescription("Delete messages containing filtered words")
- .setValue("words"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Malware")
- .setDescription("Automatically delete files and links containing malware")
- .setValue("malware"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Images")
- .setDescription("Checks performed on images (NSFW, size checking, etc.)")
- .setValue("images"),
- new StringSelectMenuOptionBuilder()
- .setLabel("Clean")
- .setDescription("Automatically delete new messages in specific channels")
- .setValue("clean")
- )
- );
+ const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("filter")
+ .setPlaceholder("Select a filter to edit")
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Invites")
+ .setDescription("Automatically delete messages containing server invites")
+ .setValue("invites"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Mentions")
+ .setDescription("Deletes messages with excessive mentions")
+ .setValue("mentions"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Words")
+ .setDescription("Delete messages containing filtered words")
+ .setValue("words"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Malware")
+ .setDescription("Automatically delete files and links containing malware")
+ .setValue("malware"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Images")
+ .setDescription("Checks performed on images (NSFW, size checking, etc.)")
+ .setValue("images"),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Clean")
+ .setDescription("Automatically delete new messages in specific channels")
+ .setValue("clean")
+ )
+ );
const embed = new EmojiEmbed()
.setTitle("Automod Settings")
.setDescription(
`${emojiFromBoolean(config.invite.enabled)} **Invites**\n` +
- `${emojiFromBoolean(config.pings.everyone || config.pings.mass > 0 || config.pings.roles)} **Mentions**\n` +
- `${emojiFromBoolean(config.wordFilter.enabled)} **Words**\n` +
- `${emojiFromBoolean(config.malware)} **Malware**\n` +
- `${emojiFromBoolean(config.images.NSFW || config.images.size)} **Images**\n` +
- `${emojiFromBoolean(config.clean.channels.length > 0)} **Clean**\n`
+ `${emojiFromBoolean(
+ config.pings.everyone || config.pings.mass > 0 || config.pings.roles
+ )} **Mentions**\n` +
+ `${emojiFromBoolean(config.wordFilter.enabled)} **Words**\n` +
+ `${emojiFromBoolean(config.malware)} **Malware**\n` +
+ `${emojiFromBoolean(config.images.NSFW || config.images.size)} **Images**\n` +
+ `${emojiFromBoolean(config.clean.channels.length > 0)} **Clean**\n`
)
.setStatus("Success")
- .setEmoji("GUILD.SETTINGS.GREEN")
+ .setEmoji("GUILD.SETTINGS.GREEN");
-
- await interaction.editReply({embeds: [embed], components: [selectMenu, button]});
+ await interaction.editReply({ embeds: [embed], components: [selectMenu, button] });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 300000}) as StringSelectMenuInteraction | ButtonInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id,
+ time: 300000
+ })) as StringSelectMenuInteraction | ButtonInteraction;
} catch (e) {
closed = true;
continue;
}
await i.deferUpdate();
- if(i.isButton()) {
- await client.database.guilds.write(interaction.guild.id, {filters: config});
+ if (i.isButton()) {
+ await client.database.guilds.write(interaction.guild.id, { filters: config });
await client.memory.forceUpdate(interaction.guild.id);
} else {
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "invites": {
config.invite = await inviteMenu(i, m, config.invite);
break;
@@ -905,10 +1103,8 @@
}
}
}
-
- } while(!closed);
- await interaction.deleteReply()
-
+ } while (!closed);
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/autopublish.ts b/src/commands/settings/autopublish.ts
index 27d01bd..afc4e7d 100644
--- a/src/commands/settings/autopublish.ts
+++ b/src/commands/settings/autopublish.ts
@@ -1,4 +1,13 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType, CommandInteraction, SlashCommandSubcommandBuilder } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonStyle,
+ ChannelSelectMenuBuilder,
+ ChannelType,
+ CommandInteraction,
+ SlashCommandSubcommandBuilder
+} from "discord.js";
import type Discord from "discord.js";
import client from "../../utils/client.js";
import { LoadingEmbed } from "../../utils/defaults.js";
@@ -21,62 +30,62 @@
let config = await client.database.guilds.read(interaction.guild!.id);
let data = _.cloneDeep(config.autoPublish);
do {
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("switch")
- .setLabel(data.enabled ? "Enabled" : "Disabled")
- .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL." + (data.enabled ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setDisabled(_.isEqual(data, config.autoPublish))
- );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("switch")
+ .setLabel(data.enabled ? "Enabled" : "Disabled")
+ .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName("CONTROL." + (data.enabled ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setDisabled(_.isEqual(data, config.autoPublish))
+ );
- const channelSelect = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel")
- .setMinValues(1)
- .setChannelTypes(ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread)
- );
+ const channelSelect = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select a channel")
+ .setMinValues(1)
+ .setChannelTypes(ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread)
+ );
const current = data.channels.map((c) => `> <#${c}>`).join("\n") || "*None set*";
const embed = new EmojiEmbed()
.setTitle("Auto Publish")
.setDescription("Currently enabled in:\n" + current)
- .setStatus('Success')
- .setEmoji("ICONS.PUBLISH")
+ .setStatus("Success")
+ .setEmoji("ICONS.PUBLISH");
- await interaction.editReply({
+ await interaction.editReply({
embeds: [embed],
components: [channelSelect, buttons]
});
let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
try {
- i = await interaction.channel!.awaitMessageComponent({
+ i = (await interaction.channel!.awaitMessageComponent({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id,
time: 300000
- }) as Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
+ })) as Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
} catch (e) {
closed = true;
continue;
}
await i.deferUpdate();
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "switch": {
data.enabled = !data.enabled;
break;
}
case "save": {
- await client.database.guilds.write(interaction.guild!.id, { "autoPublish": data });
+ await client.database.guilds.write(interaction.guild!.id, { autoPublish: data });
config = await client.database.guilds.read(interaction.guild!.id);
data = _.cloneDeep(config.autoPublish);
await client.memory.forceUpdate(interaction.guild!.id);
@@ -84,16 +93,17 @@
}
}
} else {
- await interaction.editReply({embeds: LoadingEmbed, components: []})
- for(const channel of i.values) {
- data.channels.includes(channel) ? data.channels.splice(data.channels.indexOf(channel), 1) : data.channels.push(channel);
+ await interaction.editReply({ embeds: LoadingEmbed, components: [] });
+ for (const channel of i.values) {
+ data.channels.includes(channel)
+ ? data.channels.splice(data.channels.indexOf(channel), 1)
+ : data.channels.push(channel);
}
}
-
} while (!closed);
await interaction.deleteReply();
-}
+};
export const check = (interaction: CommandInteraction, _partial: boolean = false) => {
const member = interaction.member as Discord.GuildMember;
diff --git a/src/commands/settings/logs/_meta.ts b/src/commands/settings/logs/_meta.ts
index 24a1e54..b1fe78e 100644
--- a/src/commands/settings/logs/_meta.ts
+++ b/src/commands/settings/logs/_meta.ts
@@ -3,6 +3,6 @@
const name = "logs";
const description = "Settings for logging";
-const subcommand = await group(name, description, `settings/logs`)
+const subcommand = await group(name, description, `settings/logs`);
-export { name, description, subcommand as command};
+export { name, description, subcommand as command };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 8f0b257..3ee7675 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,5 +1,12 @@
import { LoadingEmbed } from "../../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ChannelSelectMenuBuilder,
+ ChannelType
+} from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
@@ -7,9 +14,7 @@
import { getCommandMentionByName } from "../../../utils/getCommandDataByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("attachments")
- .setDescription("Where attachments should be logged to (Premium only)")
+ builder.setName("attachments").setDescription("Where attachments should be logged to (Premium only)");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (interaction.guild) client.database.premium.hasPremium(interaction.guild.id).finally(() => {});
@@ -17,54 +22,55 @@
embeds: LoadingEmbed,
ephemeral: true,
fetchReply: true
- })
-
- if(!await client.database.premium.hasPremium(interaction.guild!.id)) return interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Premium Required")
- .setDescription(`This feature is exclusive to ${getCommandMentionByName("nucleus/premium")} servers.`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.PREMIUM")
- ]
});
+ if (!(await client.database.premium.hasPremium(interaction.guild!.id)))
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Premium Required")
+ .setDescription(
+ `This feature is exclusive to ${getCommandMentionByName("nucleus/premium")} servers.`
+ )
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.PREMIUM")
+ ]
+ });
+
let data = await client.database.guilds.read(interaction.guild!.id);
let channel = data.logging.staff.channel;
let closed = false;
do {
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel")
- .setChannelTypes(ChannelType.GuildText)
- );
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("clear")
- .setLabel("Clear")
- .setStyle(ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as Discord.APIMessageComponentEmoji)
- .setDisabled(!channel),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as Discord.APIMessageComponentEmoji)
- .setDisabled(channel === data.logging.staff.channel)
- );
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select a channel")
+ .setChannelTypes(ChannelType.GuildText)
+ );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setStyle(ButtonStyle.Danger)
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as Discord.APIMessageComponentEmoji)
+ .setDisabled(!channel),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as Discord.APIMessageComponentEmoji)
+ .setDisabled(channel === data.logging.staff.channel)
+ );
const embed = new EmojiEmbed()
.setTitle("Attachments")
.setDescription(
`The channel to send all attachments from the server, allowing you to check them if they are deleted\n` +
- `**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n`
+ `**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n`
)
.setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
+ .setEmoji("CHANNEL.TEXT.CREATE");
await interaction.editReply({
embeds: [embed],
@@ -82,7 +88,7 @@
continue;
}
await i.deferUpdate();
- if(i.isButton()) {
+ if (i.isButton()) {
switch (i.customId) {
case "clear": {
channel = null;
@@ -100,9 +106,8 @@
} else {
channel = i.values[0]!;
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 05d6928..4cffab7 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,5 +1,18 @@
import { LoadingEmbed } from "../../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ChannelSelectMenuBuilder, ChannelType, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ButtonInteraction, StringSelectMenuInteraction, ChannelSelectMenuInteraction, APIMessageComponentEmoji } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ ActionRowBuilder,
+ ChannelSelectMenuBuilder,
+ ChannelType,
+ ButtonBuilder,
+ ButtonStyle,
+ StringSelectMenuBuilder,
+ StringSelectMenuOptionBuilder,
+ ButtonInteraction,
+ StringSelectMenuInteraction,
+ ChannelSelectMenuInteraction,
+ APIMessageComponentEmoji
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../../utils/client.js";
import compare from "lodash";
@@ -26,14 +39,12 @@
webhookUpdate: "Webhooks created or deleted",
guildMemberVerify: "Member runs verify",
autoModeratorDeleted: "Messages auto deleted by Nucleus",
- ticketUpdate: "Tickets created or deleted",
+ ticketUpdate: "Tickets created or deleted"
//nucleusSettingsUpdated: "Nucleus' settings updated by a moderator" // TODO
};
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("events")
- .setDescription("The general log channel for the server, and setting what events to show")
+ builder.setName("events").setDescription("The general log channel for the server, and setting what events to show");
const callback = async (interaction: CommandInteraction): Promise<void> => {
const m = (await interaction.reply({
@@ -47,52 +58,45 @@
let closed = false;
let show = false;
do {
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel")
- .setChannelTypes(ChannelType.GuildText)
- )
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("switch")
- .setLabel(data.enabled ? "Enabled" : "Disabled")
- .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName((data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS"), "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("remove")
- .setLabel("Remove")
- .setStyle(ButtonStyle.Danger)
- .setDisabled(!data.channel),
- new ButtonBuilder()
- .setCustomId("show")
- .setLabel("Manage Events")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setDisabled(compare.isEqual(data, config.logging.logs))
- )
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select a channel")
+ .setChannelTypes(ChannelType.GuildText)
+ );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("switch")
+ .setLabel(data.enabled ? "Enabled" : "Disabled")
+ .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("remove")
+ .setLabel("Remove")
+ .setStyle(ButtonStyle.Danger)
+ .setDisabled(!data.channel),
+ new ButtonBuilder().setCustomId("show").setLabel("Manage Events").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(compare.isEqual(data, config.logging.logs))
+ );
const converted = toHexArray(data.toLog);
- const toLogMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setPlaceholder("Set events to log")
- .setMaxValues(Object.keys(logs).length)
- .setCustomId("logs")
- .setMinValues(0)
- )
+ const toLogMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setPlaceholder("Set events to log")
+ .setMaxValues(Object.keys(logs).length)
+ .setCustomId("logs")
+ .setMinValues(0)
+ );
Object.keys(logs).map((e) => {
toLogMenu.components[0]!.addOptions(
- new StringSelectMenuOptionBuilder()
- .setLabel(logs[e]!)
- .setValue(e)
- .setDefault(converted.includes(e))
- )
+ new StringSelectMenuOptionBuilder().setLabel(logs[e]!).setValue(e).setDefault(converted.includes(e))
+ );
});
const embed = new EmojiEmbed()
@@ -101,11 +105,14 @@
.setEmoji("CHANNEL.TEXT.CREATE")
.setDescription(
`This is the channel that all events you set to be logged will be stored\n` +
- `**Channel:** ${data.channel ? `<#${data.channel}>` : "None"}\n`
- )
+ `**Channel:** ${data.channel ? `<#${data.channel}>` : "None"}\n`
+ );
- const components: ActionRowBuilder<ButtonBuilder | ChannelSelectMenuBuilder | StringSelectMenuBuilder>[] = [channelMenu, buttons];
- if(show) components.push(toLogMenu);
+ const components: ActionRowBuilder<ButtonBuilder | ChannelSelectMenuBuilder | StringSelectMenuBuilder>[] = [
+ channelMenu,
+ buttons
+ ];
+ if (show) components.push(toLogMenu);
await interaction.editReply({
embeds: [embed],
@@ -114,10 +121,10 @@
let i: ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({
+ i = (await m.awaitMessageComponent({
filter: (i) => i.user.id === interaction.user.id,
time: 300000
- }) as ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction;
+ })) as ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction;
} catch (e) {
closed = true;
continue;
@@ -125,8 +132,8 @@
await i.deferUpdate();
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "show": {
show = !show;
break;
@@ -136,10 +143,10 @@
break;
}
case "save": {
- await client.database.guilds.write(interaction.guild!.id, {"logging.logs": data});
+ await client.database.guilds.write(interaction.guild!.id, { "logging.logs": data });
config = await client.database.guilds.read(interaction.guild!.id);
data = Object.assign({}, config.logging.logs);
- await client.memory.forceUpdate(interaction.guild!.id)
+ await client.memory.forceUpdate(interaction.guild!.id);
break;
}
case "remove": {
@@ -147,15 +154,14 @@
break;
}
}
- } else if(i.isStringSelectMenu()) {
+ } else if (i.isStringSelectMenu()) {
const hex = toHexInteger(i.values);
data.toLog = hex;
- } else if(i.isChannelSelectMenu()) {
+ } else if (i.isChannelSelectMenu()) {
data.channel = i.values[0]!;
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/logs/warnings.ts b/src/commands/settings/logs/warnings.ts
index 4d9a3fa..38b645a 100644
--- a/src/commands/settings/logs/warnings.ts
+++ b/src/commands/settings/logs/warnings.ts
@@ -1,14 +1,19 @@
import { LoadingEmbed } from "../../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ChannelSelectMenuBuilder,
+ ChannelType
+} from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("warnings")
- .setDescription("Settings for the staff notifications channel")
+ builder.setName("warnings").setDescription("Settings for the staff notifications channel");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
@@ -16,34 +21,32 @@
embeds: LoadingEmbed,
ephemeral: true,
fetchReply: true
- })
+ });
let data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
let closed = false;
do {
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
new ChannelSelectMenuBuilder()
.setCustomId("channel")
.setPlaceholder("Select a channel")
.setChannelTypes(ChannelType.GuildText)
);
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("clear")
- .setLabel("Clear")
- .setStyle(ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as Discord.APIMessageComponentEmoji)
- .setDisabled(!channel),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as Discord.APIMessageComponentEmoji)
- .setDisabled(channel === data.logging.staff.channel)
- );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setStyle(ButtonStyle.Danger)
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as Discord.APIMessageComponentEmoji)
+ .setDisabled(!channel),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as Discord.APIMessageComponentEmoji)
+ .setDisabled(channel === data.logging.staff.channel)
+ );
const embed = new EmojiEmbed()
.setTitle("Staff Notifications Channel")
@@ -51,8 +54,8 @@
.setEmoji("CHANNEL.TEXT.CREATE")
.setDescription(
`Logs which require an action from a moderator or administrator will be sent to this channel.\n` +
- `**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n`
- )
+ `**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n`
+ );
await interaction.editReply({
embeds: [embed],
@@ -70,7 +73,7 @@
continue;
}
await i.deferUpdate();
- if(i.isButton()) {
+ if (i.isButton()) {
switch (i.customId) {
case "clear": {
channel = null;
@@ -90,7 +93,7 @@
}
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/moderation.ts b/src/commands/settings/moderation.ts
index 336e53a..6ee6e1e 100644
--- a/src/commands/settings/moderation.ts
+++ b/src/commands/settings/moderation.ts
@@ -1,5 +1,13 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ButtonComponent, TextInputBuilder, RoleSelectMenuBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ ButtonComponent,
+ TextInputBuilder,
+ RoleSelectMenuBuilder
+} from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
@@ -9,7 +17,7 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("moderation")
- .setDescription("Links and text shown to a user after a moderator action is performed")
+ .setDescription("Links and text shown to a user after a moderator action is performed");
const callback = async (interaction: CommandInteraction): Promise<void> => {
const m = await interaction.reply({
@@ -21,7 +29,7 @@
while (!timedOut) {
const config = await client.database.guilds.read(interaction.guild!.id);
const moderation = config.moderation;
- console.log(moderation)
+ console.log(moderation);
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -30,7 +38,8 @@
.setStatus("Success")
.setDescription(
"These links are shown below the message sent in a user's DM when they are punished.\n\n" +
- "**Mute Role:** " + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
+ "**Mute Role:** " +
+ (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
)
],
components: [
@@ -76,9 +85,7 @@
.setEmoji(getEmojiByName("CONTROL." + (moderation.mute.timeout ? "TICK" : "CROSS"), "id"))
]),
new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("muteRole")
- .setPlaceholder("Select a new mute role")
+ new RoleSelectMenuBuilder().setCustomId("muteRole").setPlaceholder("Select a new mute role")
)
]
});
@@ -86,7 +93,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -112,24 +125,28 @@
.setCustomId("modal")
.setTitle(`Options for ${i.customId}`)
.addComponents(
- new ActionRowBuilder<TextInputBuilder>().addComponents(
- new TextInputBuilder()
- .setCustomId("name")
- .setLabel("Button text")
- .setMaxLength(100)
- .setRequired(false)
- .setStyle(Discord.TextInputStyle.Short)
- .setValue(chosen.text ?? "")
- ).toJSON(),
- new ActionRowBuilder<TextInputBuilder>().addComponents(
- new TextInputBuilder()
- .setCustomId("url")
- .setLabel("URL - Type {id} to insert the user's ID")
- .setMaxLength(2000)
- .setRequired(false)
- .setStyle(Discord.TextInputStyle.Short)
- .setValue(chosen.link ?? "")
- ).toJSON()
+ new ActionRowBuilder<TextInputBuilder>()
+ .addComponents(
+ new TextInputBuilder()
+ .setCustomId("name")
+ .setLabel("Button text")
+ .setMaxLength(100)
+ .setRequired(false)
+ .setStyle(Discord.TextInputStyle.Short)
+ .setValue(chosen.text ?? "")
+ )
+ .toJSON(),
+ new ActionRowBuilder<TextInputBuilder>()
+ .addComponents(
+ new TextInputBuilder()
+ .setCustomId("url")
+ .setLabel("URL - Type {id} to insert the user's ID")
+ .setMaxLength(2000)
+ .setRequired(false)
+ .setStyle(Discord.TextInputStyle.Short)
+ .setValue(chosen.link ?? "")
+ )
+ .toJSON()
)
);
await interaction.editReply({
@@ -152,11 +169,11 @@
});
let out: Discord.ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as Discord.ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(m, interaction.user)) as Discord.ModalSubmitInteraction | null;
} catch (e) {
continue;
}
- if (!out || out.isButton()) continue
+ if (!out || out.isButton()) continue;
const buttonText = out.fields.getTextInputValue("name");
const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
const current = chosen;
@@ -171,7 +188,7 @@
}
}
}
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index ae174b3..11c6b67 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -1,5 +1,21 @@
import type Discord from "discord.js";
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, Message, ModalBuilder, RoleSelectMenuBuilder, RoleSelectMenuInteraction, StringSelectMenuBuilder, StringSelectMenuInteraction, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ CommandInteraction,
+ Message,
+ ModalBuilder,
+ RoleSelectMenuBuilder,
+ RoleSelectMenuInteraction,
+ StringSelectMenuBuilder,
+ StringSelectMenuInteraction,
+ StringSelectMenuOptionBuilder,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { LoadingEmbed } from "../../utils/defaults.js";
@@ -9,14 +25,11 @@
import { configToDropdown } from "../../actions/roleMenu.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
import ellipsis from "../../utils/ellipsis.js";
-import lodash from 'lodash';
+import lodash from "lodash";
const isEqual = lodash.isEqual;
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("rolemenu")
- .setDescription("rolemenu")
+const command = (builder: SlashCommandSubcommandBuilder) => builder.setName("rolemenu").setDescription("rolemenu");
interface ObjectSchema {
name: string;
@@ -35,34 +48,27 @@
description: "A new role menu page",
min: 0,
max: 0,
- options: [
- {name: "Role 1", description: null, role: "No role set"}
- ]
-}
+ options: [{ name: "Role 1", description: null, role: "No role set" }]
+};
const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => {
- const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("reorder")
- .setPlaceholder("Select all pages in the order you want them to appear.")
- .setMinValues(currentObj.length)
- .setMaxValues(currentObj.length)
- .addOptions(
- currentObj.map((o, i) => new StringSelectMenuOptionBuilder()
- .setLabel(o.name)
- .setValue(i.toString())
- )
- )
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("reorder")
+ .setPlaceholder("Select all pages in the order you want them to appear.")
+ .setMinValues(currentObj.length)
+ .setMaxValues(currentObj.length)
+ .addOptions(
+ currentObj.map((o, i) => new StringSelectMenuOptionBuilder().setLabel(o.name).setValue(i.toString()))
+ )
+ );
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -74,64 +80,65 @@
});
let out: StringSelectMenuInteraction | ButtonInteraction | null;
try {
- out = await m.awaitMessageComponent({
+ out = (await m.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
- }) as StringSelectMenuInteraction | ButtonInteraction | null;
+ })) as StringSelectMenuInteraction | ButtonInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return;
+ if (!out) return;
out.deferUpdate();
if (out.isButton()) return;
const values = out.values;
const newOrder: ObjectSchema[] = currentObj.map((_, i) => {
- const index = values.findIndex(v => v === i.toString());
+ const index = values.findIndex((v) => v === i.toString());
return currentObj[index];
}) as ObjectSchema[];
return newOrder;
-}
+};
-const editNameDescription = async (i: ButtonInteraction, interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data: {name?: string, description?: string}) => {
-
- let {name, description} = data;
+const editNameDescription = async (
+ i: ButtonInteraction,
+ interaction: StringSelectMenuInteraction | ButtonInteraction,
+ m: Message,
+ data: { name?: string; description?: string }
+) => {
+ let { name, description } = data;
const modal = new ModalBuilder()
.setTitle("Edit Name and Description")
.setCustomId("editNameDescription")
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setLabel("Name")
- .setCustomId("name")
- .setPlaceholder("The name of the role (e.g. Programmer)")
- .setStyle(TextInputStyle.Short)
- .setValue(name ?? "")
- .setRequired(true)
- ),
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setLabel("Description")
- .setCustomId("description")
- .setPlaceholder("A short description of the role (e.g. A role for people who code)")
- .setStyle(TextInputStyle.Short)
- .setValue(description ?? "")
- )
- )
- const button = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setLabel("Name")
+ .setCustomId("name")
+ .setPlaceholder("The name of the role (e.g. Programmer)")
+ .setStyle(TextInputStyle.Short)
+ .setValue(name ?? "")
+ .setRequired(true)
+ ),
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setLabel("Description")
+ .setCustomId("description")
+ .setPlaceholder("A short description of the role (e.g. A role for people who code)")
+ .setStyle(TextInputStyle.Short)
+ .setValue(description ?? "")
+ )
+ );
+ const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
- await i.showModal(modal)
+ await i.showModal(modal);
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -144,76 +151,93 @@
let out: Discord.ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as Discord.ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(m, interaction.user)) as Discord.ModalSubmitInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return [name, description];
+ if (!out) return [name, description];
if (out.isButton()) return [name, description];
name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
description = out.fields.fields.find((f) => f.customId === "description")?.value ?? description;
- return [name, description]
+ return [name, description];
+};
-}
+const editRoleMenuPage = async (
+ interaction: StringSelectMenuInteraction | ButtonInteraction,
+ m: Message,
+ data?: ObjectSchema
+): Promise<ObjectSchema | null> => {
+ if (!data)
+ data = {
+ name: "Role Menu Page",
+ description: "A new role menu page",
+ min: 0,
+ max: 0,
+ options: []
+ };
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("edit")
+ .setLabel("Edit")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("addRole")
+ .setLabel("Add Role")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ );
-const editRoleMenuPage = async (interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data?: ObjectSchema): Promise<ObjectSchema | null> => {
- if (!data) data = {
- name: "Role Menu Page",
- description: "A new role menu page",
- min: 0,
- max: 0,
- options: []
- };
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("edit")
- .setLabel("Edit")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("addRole")
- .setLabel("Add Role")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
- );
-
- let back = false
- if(data.options.length === 0) {
- data.options = [
- {name: "Role 1", description: null, role: "No role set"}
- ]
+ let back = false;
+ if (data.options.length === 0) {
+ data.options = [{ name: "Role 1", description: null, role: "No role set" }];
}
do {
- const previewSelect = configToDropdown("Edit Roles", {name: data.name, description: data.description, min: 1, max: 1, options: data.options});
+ const previewSelect = configToDropdown("Edit Roles", {
+ name: data.name,
+ description: data.description,
+ min: 1,
+ max: 1,
+ options: data.options
+ });
const embed = new EmojiEmbed()
.setTitle(`${data.name}`)
.setStatus("Success")
.setDescription(
`**Description:**\n> ${data.description}\n\n` +
- `**Min:** ${data.min}` + (data.min === 0 ? " (Members will be given a skip button)" : "") + "\n" +
- `**Max:** ${data.max}\n`
- )
+ `**Min:** ${data.min}` +
+ (data.min === 0 ? " (Members will be given a skip button)" : "") +
+ "\n" +
+ `**Max:** ${data.max}\n`
+ );
- interaction.editReply({embeds: [embed], components: [previewSelect, buttons]});
+ interaction.editReply({ embeds: [embed], components: [previewSelect, buttons] });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
back = true;
break;
}
if (i.isStringSelectMenu()) {
- if(i.customId === "roles") {
+ if (i.customId === "roles") {
await i.deferUpdate();
- await createRoleMenuOptionPage(interaction, m, data.options.find((o) => o.role === (i as StringSelectMenuInteraction).values[0]));
+ await createRoleMenuOptionPage(
+ interaction,
+ m,
+ data.options.find((o) => o.role === (i as StringSelectMenuInteraction).values[0])
+ );
}
} else if (i.isButton()) {
switch (i.customId) {
@@ -235,55 +259,69 @@
}
}
}
-
} while (!back);
- if(isEqual(data, defaultRolePageConfig)) return null;
+ if (isEqual(data, defaultRolePageConfig)) return null;
return data;
-}
+};
-const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data?: {name: string; description: string | null; role: string}) => {
- const { renderRole} = client.logger;
- if (!data) data = {
- name: "New role Menu Option",
- description: null,
- role: ""
- };
+const createRoleMenuOptionPage = async (
+ interaction: StringSelectMenuInteraction | ButtonInteraction,
+ m: Message,
+ data?: { name: string; description: string | null; role: string }
+) => {
+ const { renderRole } = client.logger;
+ if (!data)
+ data = {
+ name: "New role Menu Option",
+ description: null,
+ role: ""
+ };
let back = false;
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("edit")
- .setLabel("Edit Details")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji)
- );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("edit")
+ .setLabel("Edit Details")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji)
+ );
do {
- const roleSelect = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder(data.role ? "Set role to" : "Set the role");
+ const roleSelect = new RoleSelectMenuBuilder()
+ .setCustomId("role")
+ .setPlaceholder(data.role ? "Set role to" : "Set the role");
const embed = new EmojiEmbed()
.setTitle(`${data.name}`)
.setStatus("Success")
.setDescription(
`**Description:**\n> ${data.description ?? "No description set"}\n\n` +
- `**Role:** ${data.role ? renderRole((await interaction.guild!.roles.fetch(data.role))!) : "No role set"}\n`
- )
+ `**Role:** ${
+ data.role ? renderRole((await interaction.guild!.roles.fetch(data.role))!) : "No role set"
+ }\n`
+ );
- interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect), buttons]});
+ interaction.editReply({
+ embeds: [embed],
+ components: [new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect), buttons]
+ });
let i: RoleSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | RoleSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId
+ })) as ButtonInteraction | RoleSelectMenuInteraction;
} catch (e) {
back = true;
break;
}
if (i.isRoleSelectMenu()) {
- if(i.customId === "role") {
+ if (i.customId === "role") {
await i.deferUpdate();
data.role = (i as RoleSelectMenuInteraction).values[0]!;
}
@@ -296,7 +334,12 @@
}
case "edit": {
await i.deferUpdate();
- const [name, description] = await editNameDescription(i, interaction, m, data as {name: string; description: string});
+ const [name, description] = await editNameDescription(
+ i,
+ interaction,
+ m,
+ data as { name: string; description: string }
+ );
data.name = name ? name : data.name;
data.description = description ? description : data.description;
break;
@@ -305,11 +348,11 @@
}
} while (!back);
return data;
-}
+};
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
let page = 0;
let closed = false;
@@ -317,10 +360,7 @@
let currentObject: ObjectSchema[] = config.roleMenu.options;
let modified = false;
do {
- const embed = new EmojiEmbed()
- .setTitle("Role Menu")
- .setEmoji("GUILD.GREEN")
- .setStatus("Success");
+ const embed = new EmojiEmbed().setTitle("Role Menu").setEmoji("GUILD.GREEN").setStatus("Success");
const noRoleMenus = currentObject.length === 0;
let current: ObjectSchema;
@@ -341,54 +381,52 @@
.setDescription("Delete this page")
.setValue("delete")
.setEmoji(getEmojiByName("TICKETS.ISSUE", "id") as APIMessageComponentEmoji)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- .setDisabled(page === 0),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Primary)
- .setDisabled(page === Object.keys(currentObject).length - 1),
- new ButtonBuilder()
- .setCustomId("add")
- .setLabel("New Page")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(Object.keys(currentObject).length >= 24),
- new ButtonBuilder()
- .setCustomId("reorder")
- .setLabel("Reorder Pages")
- .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(Object.keys(currentObject).length <= 1),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success)
- .setDisabled(!modified),
);
- if(noRoleMenus) {
- embed.setDescription("No role menu pages have been set up yet. Use the button below to add one.\n\n" +
- createPageIndicator(1, 1, undefined, true)
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ .setDisabled(page === 0),
+ new ButtonBuilder()
+ .setCustomId("next")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(page === Object.keys(currentObject).length - 1),
+ new ButtonBuilder()
+ .setCustomId("add")
+ .setLabel("New Page")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(currentObject).length >= 24),
+ new ButtonBuilder()
+ .setCustomId("reorder")
+ .setLabel("Reorder Pages")
+ .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(currentObject).length <= 1),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(!modified)
+ );
+ if (noRoleMenus) {
+ embed.setDescription(
+ "No role menu pages have been set up yet. Use the button below to add one.\n\n" +
+ createPageIndicator(1, 1, undefined, true)
);
pageSelect.setDisabled(true);
actionSelect.setDisabled(true);
- pageSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel("No role menu pages")
- .setValue("none")
- );
+ pageSelect.addOptions(new StringSelectMenuOptionBuilder().setLabel("No role menu pages").setValue("none"));
} else {
page = Math.min(page, Object.keys(currentObject).length - 1);
current = currentObject[page]!;
- embed.setDescription(`**Currently Editing:** ${current.name}\n\n` +
- `**Description:**\n> ${current.description}\n` +
- `\n\n${createPageIndicator(Object.keys(config.roleMenu.options).length, page)}`
+ embed.setDescription(
+ `**Currently Editing:** ${current.name}\n\n` +
+ `**Description:**\n> ${current.description}\n` +
+ `\n\n${createPageIndicator(Object.keys(config.roleMenu.options).length, page)}`
);
pageSelect.addOptions(
@@ -399,13 +437,23 @@
.setValue(index.toString());
})
);
-
}
- await interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect), new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect), buttonRow]});
+ await interaction.editReply({
+ embeds: [embed],
+ components: [
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
+ buttonRow
+ ]
+ });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
closed = true;
continue;
@@ -423,20 +471,20 @@
break;
}
case "add": {
- const newPage = await editRoleMenuPage(i, m)
- if(!newPage) break;
+ const newPage = await editRoleMenuPage(i, m);
+ if (!newPage) break;
currentObject.push();
page = currentObject.length - 1;
break;
}
case "reorder": {
const reordered = await reorderRoleMenuPages(interaction, m, currentObject);
- if(!reordered) break;
+ if (!reordered) break;
currentObject = reordered;
break;
}
case "save": {
- await client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});
+ await client.database.guilds.write(interaction.guild.id, { "roleMenu.options": currentObject });
modified = false;
await client.memory.forceUpdate(interaction.guild.id);
break;
@@ -445,16 +493,16 @@
} else if (i.isStringSelectMenu()) {
switch (i.customId) {
case "action": {
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "edit": {
const edited = await editRoleMenuPage(i, m, current!);
- if(!edited) break;
+ if (!edited) break;
currentObject[page] = edited;
modified = true;
break;
}
case "delete": {
- if(page === 0 && currentObject.keys.length - 1 > 0) page++;
+ if (page === 0 && currentObject.keys.length - 1 > 0) page++;
else page--;
currentObject.splice(page, 1);
break;
@@ -468,9 +516,8 @@
}
}
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index ecab612..d4e4439 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,5 +1,21 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, Message, ActionRowBuilder, StringSelectMenuBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuOptionBuilder, APIMessageComponentEmoji, TextInputBuilder, StringSelectMenuInteraction, ButtonInteraction, MessageComponentInteraction, ChannelSelectMenuBuilder, ChannelSelectMenuInteraction, ModalBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ Message,
+ ActionRowBuilder,
+ StringSelectMenuBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ StringSelectMenuOptionBuilder,
+ APIMessageComponentEmoji,
+ TextInputBuilder,
+ StringSelectMenuInteraction,
+ ButtonInteraction,
+ MessageComponentInteraction,
+ ChannelSelectMenuBuilder,
+ ChannelSelectMenuInteraction,
+ ModalBuilder
+} from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../utils/client.js";
@@ -9,14 +25,10 @@
import createPageIndicator from "../../utils/createPageIndicator.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("stats")
- .setDescription("Controls channels which update when someone joins or leaves the server")
+ builder.setName("stats").setDescription("Controls channels which update when someone joins or leaves the server");
-
-const showModal = async (interaction: MessageComponentInteraction, current: { enabled: boolean; name: string; }) => {
+const showModal = async (interaction: MessageComponentInteraction, current: { enabled: boolean; name: string }) => {
await interaction.showModal(
new ModalBuilder()
.setCustomId("modal")
@@ -28,7 +40,7 @@
.setLabel("Server Info (1/3)")
.setPlaceholder(
`{serverName} - This server's name\n\n` +
- `These placeholders will be replaced with the server's name, etc..`
+ `These placeholders will be replaced with the server's name, etc..`
)
.setMaxLength(1)
.setRequired(false)
@@ -40,8 +52,8 @@
.setLabel("Member Counts (2/3) - {MemberCount:...}")
.setPlaceholder(
`{:all} - Total member count\n` +
- `{:humans} - Total non-bot users\n` +
- `{:bots} - Number of bots\n`
+ `{:humans} - Total non-bot users\n` +
+ `{:bots} - Number of bots\n`
)
.setMaxLength(1)
.setRequired(false)
@@ -51,9 +63,7 @@
new TextInputBuilder()
.setCustomId("ex3")
.setLabel("Latest Member (3/3) - {member:...}")
- .setPlaceholder(
- `{:name} - The members name\n`
- )
+ .setPlaceholder(`{:name} - The members name\n`)
.setMaxLength(1)
.setRequired(false)
.setStyle(Discord.TextInputStyle.Paragraph)
@@ -69,35 +79,46 @@
)
)
);
-}
+};
-type ObjectSchema = Record<string, {name: string, enabled: boolean}>
+type ObjectSchema = Record<string, { name: string; enabled: boolean }>;
-
-const addStatsChannel = async (interaction: CommandInteraction, m: Message, currentObject: ObjectSchema): Promise<ObjectSchema> => {
+const addStatsChannel = async (
+ interaction: CommandInteraction,
+ m: Message,
+ currentObject: ObjectSchema
+): Promise<ObjectSchema> => {
let closed = false;
let cancelled = false;
- const originalObject = Object.fromEntries(Object.entries(currentObject).map(([k, v]) => [k, {...v}]));
+ const originalObject = Object.fromEntries(Object.entries(currentObject).map(([k, v]) => [k, { ...v }]));
let newChannel: string | undefined;
let newChannelName: string = "{memberCount:all}-members";
let newChannelEnabled: boolean = true;
do {
m = await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription(
- `New stats channel` + (newChannel ? ` in <#${newChannel}>` : "") + "\n\n" +
- `**Name:** \`${newChannelName}\`\n` +
- `**Preview:** ${await convertCurlyBracketString(newChannelName, interaction.user!.id, interaction.user.username, interaction.guild!.name, interaction.guild!.members)}\n` +
- `**Enabled:** ${newChannelEnabled ? "Yes" : "No"}\n\n`
- )
- .setEmoji("SETTINGS.STATS.GREEN")
- .setStatus("Success")
- ], components: [
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats Channel")
+ .setDescription(
+ `New stats channel` +
+ (newChannel ? ` in <#${newChannel}>` : "") +
+ "\n\n" +
+ `**Name:** \`${newChannelName}\`\n` +
+ `**Preview:** ${await convertCurlyBracketString(
+ newChannelName,
+ interaction.user!.id,
+ interaction.user.username,
+ interaction.guild!.name,
+ interaction.guild!.members
+ )}\n` +
+ `**Enabled:** ${newChannelEnabled ? "Yes" : "No"}\n\n`
+ )
+ .setEmoji("SETTINGS.STATS.GREEN")
+ .setStatus("Success")
+ ],
+ components: [
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel to use")
+ new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select a channel to use")
),
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
@@ -125,9 +146,16 @@
});
let i: ButtonInteraction | ChannelSelectMenuInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => {
- return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id;
- }}) as ButtonInteraction | ChannelSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
+ })) as ButtonInteraction | ChannelSelectMenuInteraction;
} catch (e) {
closed = true;
cancelled = true;
@@ -146,18 +174,19 @@
currentObject[newChannel] = {
name: newChannelName,
enabled: newChannelEnabled
- }
+ };
}
closed = true;
break;
}
case "editName": {
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("SETTINGS.STATS.GREEN")
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats Channel")
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
+ .setStatus("Success")
+ .setEmoji("SETTINGS.STATS.GREEN")
],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
@@ -169,9 +198,10 @@
)
]
});
- showModal(i, {name: newChannelName, enabled: newChannelEnabled})
+ showModal(i, { name: newChannelName, enabled: newChannelEnabled });
- const out: Discord.ModalSubmitInteraction | ButtonInteraction| null = await modalInteractionCollector(m, interaction.user);
+ const out: Discord.ModalSubmitInteraction | ButtonInteraction | null =
+ await modalInteractionCollector(m, interaction.user);
if (!out) continue;
if (out.isButton()) continue;
newChannelName = out.fields.getTextInputValue("text");
@@ -189,11 +219,11 @@
newChannel = i.values[0];
}
}
- } while (!closed)
+ } while (!closed);
if (cancelled) return originalObject;
if (!(newChannel && newChannelName && newChannelEnabled)) return originalObject;
return currentObject;
-}
+};
const callback = async (interaction: CommandInteraction) => {
if (!interaction.guild) return;
const { renderChannel } = client.logger;
@@ -204,12 +234,9 @@
let currentObject: ObjectSchema = config.stats;
let modified = false;
do {
- const embed = new EmojiEmbed()
- .setTitle("Stats Settings")
- .setEmoji("SETTINGS.STATS.GREEN")
- .setStatus("Success");
+ const embed = new EmojiEmbed().setTitle("Stats Settings").setEmoji("SETTINGS.STATS.GREEN").setStatus("Success");
const noStatsChannels = Object.keys(currentObject).length === 0;
- let current: { enabled: boolean; name: string; };
+ let current: { enabled: boolean; name: string };
const pageSelect = new StringSelectMenuBuilder()
.setCustomId("page")
@@ -228,83 +255,109 @@
.setDescription("Delete the stats channel")
.setValue("delete")
.setEmoji(getEmojiByName("TICKETS.ISSUE", "id") as APIMessageComponentEmoji)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- .setDisabled(page === 0),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Primary)
- .setDisabled(page === Object.keys(currentObject).length - 1),
- new ButtonBuilder()
- .setCustomId("add")
- .setLabel("Create new")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(Object.keys(currentObject).length >= 24),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success)
- .setDisabled(modified),
);
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ .setDisabled(page === 0),
+ new ButtonBuilder()
+ .setCustomId("next")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(page === Object.keys(currentObject).length - 1),
+ new ButtonBuilder()
+ .setCustomId("add")
+ .setLabel("Create new")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(currentObject).length >= 24),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(modified)
+ );
if (noStatsChannels) {
- embed.setDescription("No stats channels have been set up yet. Use the button below to add one.\n\n" +
- createPageIndicator(1, 1, undefined, true)
+ embed.setDescription(
+ "No stats channels have been set up yet. Use the button below to add one.\n\n" +
+ createPageIndicator(1, 1, undefined, true)
);
pageSelect.setDisabled(true);
actionSelect.setDisabled(true);
- pageSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel("No stats channels")
- .setValue("none")
- );
+ pageSelect.addOptions(new StringSelectMenuOptionBuilder().setLabel("No stats channels").setValue("none"));
} else {
page = Math.min(page, Object.keys(currentObject).length - 1);
- current = currentObject[Object.keys(config.stats)[page]!]!
- actionSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel(current.enabled ? "Disable" : "Enable")
- .setValue("toggleEnabled")
- .setDescription(`Currently ${current.enabled ? "Enabled" : "Disabled"}, click to ${current.enabled ? "disable" : "enable"} this channel`)
- .setEmoji(getEmojiByName(current.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji)
+ current = currentObject[Object.keys(config.stats)[page]!]!;
+ actionSelect.addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel(current.enabled ? "Disable" : "Enable")
+ .setValue("toggleEnabled")
+ .setDescription(
+ `Currently ${current.enabled ? "Enabled" : "Disabled"}, click to ${
+ current.enabled ? "disable" : "enable"
+ } this channel`
+ )
+ .setEmoji(
+ getEmojiByName(
+ current.enabled ? "CONTROL.TICK" : "CONTROL.CROSS",
+ "id"
+ ) as APIMessageComponentEmoji
+ )
);
- embed.setDescription(`**Currently Editing:** ${renderChannel(Object.keys(currentObject)[page]!)}\n\n` +
- `${getEmojiByName(current.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Currently ${current.enabled ? "Enabled" : "Disabled"}\n` +
- `**Name:** \`${current.name}\`\n` +
- `**Preview:** ${await convertCurlyBracketString(current.name, interaction.user.id, interaction.user.username, interaction.guild.name, interaction.guild.members)}` + '\n\n' +
- createPageIndicator(Object.keys(config.stats).length, page)
+ embed.setDescription(
+ `**Currently Editing:** ${renderChannel(Object.keys(currentObject)[page]!)}\n\n` +
+ `${getEmojiByName(current.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Currently ${
+ current.enabled ? "Enabled" : "Disabled"
+ }\n` +
+ `**Name:** \`${current.name}\`\n` +
+ `**Preview:** ${await convertCurlyBracketString(
+ current.name,
+ interaction.user.id,
+ interaction.user.username,
+ interaction.guild.name,
+ interaction.guild.members
+ )}` +
+ "\n\n" +
+ createPageIndicator(Object.keys(config.stats).length, page)
);
for (const [id, { name, enabled }] of Object.entries(currentObject)) {
- pageSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel(`${name} (${renderChannel(id)})`)
- .setEmoji(getEmojiByName(enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji)
- .setDescription(`${enabled ? "Enabled" : "Disabled"}`)
- .setValue(id)
+ pageSelect.addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel(`${name} (${renderChannel(id)})`)
+ .setEmoji(
+ getEmojiByName(enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji
+ )
+ .setDescription(`${enabled ? "Enabled" : "Disabled"}`)
+ .setValue(id)
);
}
}
- interaction.editReply({embeds: [embed], components: [
- new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
- new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
- buttonRow
- ]});
+ interaction.editReply({
+ embeds: [embed],
+ components: [
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
+ buttonRow
+ ]
+ });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ filter: (interaction) => interaction.user.id === interaction.user.id, time: 60000 }) as StringSelectMenuInteraction | ButtonInteraction;
+ i = (await m.awaitMessageComponent({
+ filter: (interaction) => interaction.user.id === interaction.user.id,
+ time: 60000
+ })) as StringSelectMenuInteraction | ButtonInteraction;
} catch (e) {
closed = true;
continue;
}
- if(i.isStringSelectMenu()) {
- switch(i.customId) {
+ if (i.isStringSelectMenu()) {
+ switch (i.customId) {
case "page": {
await i.deferUpdate();
page = Object.keys(currentObject).indexOf(i.values[0]!);
@@ -312,9 +365,9 @@
}
case "action": {
modified = true;
- switch(i.values[0]!) {
+ switch (i.values[0]!) {
case "edit": {
- showModal(i, current!)
+ showModal(i, current!);
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -335,24 +388,31 @@
});
let out: Discord.ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as Discord.ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(
+ m,
+ interaction.user
+ )) as Discord.ModalSubmitInteraction | null;
} catch (e) {
continue;
}
- if (!out) continue
+ if (!out) continue;
if (out.isButton()) continue;
- currentObject[Object.keys(currentObject)[page]!]!.name = out.fields.getTextInputValue("text");
+ currentObject[Object.keys(currentObject)[page]!]!.name =
+ out.fields.getTextInputValue("text");
break;
}
case "toggleEnabled": {
await i.deferUpdate();
- currentObject[Object.keys(currentObject)[page]!]!.enabled = !currentObject[Object.keys(currentObject)[page]!]!.enabled;
+ currentObject[Object.keys(currentObject)[page]!]!.enabled =
+ !currentObject[Object.keys(currentObject)[page]!]!.enabled;
modified = true;
break;
}
case "delete": {
await i.deferUpdate();
- currentObject = Object.fromEntries(Object.entries(currentObject).filter(([k]) => k !== Object.keys(currentObject)[page]!));
+ currentObject = Object.fromEntries(
+ Object.entries(currentObject).filter(([k]) => k !== Object.keys(currentObject)[page]!)
+ );
page = Math.min(page, Object.keys(currentObject).length - 1);
modified = true;
break;
@@ -363,7 +423,7 @@
}
} else {
await i.deferUpdate();
- switch(i.customId) {
+ switch (i.customId) {
case "back": {
page--;
break;
@@ -378,7 +438,7 @@
break;
}
case "save": {
- await client.database.guilds.write(interaction.guild.id, {stats: currentObject});
+ await client.database.guilds.write(interaction.guild.id, { stats: currentObject });
singleNotify("statsChannelDeleted", interaction.guild.id, true);
modified = false;
await client.memory.forceUpdate(interaction.guild.id);
@@ -386,9 +446,8 @@
}
}
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
@@ -398,7 +457,6 @@
return true;
};
-
export { command };
export { callback };
export { check };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 838defb..c0025d8 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -30,9 +30,7 @@
import { LinkWarningFooter } from "../../utils/defaults.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("tickets")
- .setDescription("Shows settings for tickets")
+ builder.setName("tickets").setDescription("Shows settings for tickets");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
@@ -45,7 +43,7 @@
data.tickets.customTypes = (data.tickets.customTypes ?? []).filter(
(value: string, index: number, array: string[]) => array.indexOf(value) === index
);
- let ticketData = (await client.database.guilds.read(interaction.guild.id)).tickets
+ let ticketData = (await client.database.guilds.read(interaction.guild.id)).tickets;
let changesMade = false;
let timedOut = false;
let errorMessage = "";
@@ -54,23 +52,28 @@
.setTitle("Tickets")
.setDescription(
`${ticketData.enabled ? "" : getEmojiByName("TICKETS.REPORT")} **Enabled:** ${
- ticketData.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
+ ticketData.enabled
+ ? `${getEmojiByName("CONTROL.TICK")} Yes`
+ : `${getEmojiByName("CONTROL.CROSS")} No`
}\n` +
`${ticketData.category ? "" : getEmojiByName("TICKETS.REPORT")}` +
- ((await interaction.guild.channels.fetch(ticketData.category!))!.type === ChannelType.GuildCategory ?
- `**Category:** ` : `**Channel:** `) + // TODO: Notify if permissions are wrong
+ ((await interaction.guild.channels.fetch(ticketData.category!))!.type === ChannelType.GuildCategory
+ ? `**Category:** `
+ : `**Channel:** `) + // TODO: Notify if permissions are wrong
`${ticketData.category ? `<#${ticketData.category}>` : "*None set*"}\n` +
`**Max Tickets:** ${ticketData.maxTickets ? ticketData.maxTickets : "*No limit*"}\n` +
`**Support Ping:** ${ticketData.supportRole ? `<@&${ticketData.supportRole}>` : "*None set*"}\n\n` +
- (ticketData.useCustom && ticketData.customTypes === null ? `${getEmojiByName("TICKETS.REPORT")} ` : "") +
+ (ticketData.useCustom && ticketData.customTypes === null
+ ? `${getEmojiByName("TICKETS.REPORT")} `
+ : "") +
`${ticketData.useCustom ? "Custom" : "Default"} types in use` +
"\n\n" +
`${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN");
- if (errorMessage) embed.setFooter({text: errorMessage, iconURL: LinkWarningFooter.iconURL});
- m = (await interaction.editReply({
+ if (errorMessage) embed.setFooter({ text: errorMessage, iconURL: LinkWarningFooter.iconURL });
+ m = await interaction.editReply({
embeds: [embed],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
@@ -111,12 +114,18 @@
.setDisabled(!ticketData.enabled)
)
]
- }));
+ });
let i: RoleSelectMenuInteraction | ButtonInteraction | ChannelSelectMenuInteraction;
try {
i = await m.awaitMessageComponent<2 | 6 | 8>({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -130,7 +139,7 @@
await i.deferUpdate();
ticketData.category = i.values[0] ?? null;
} else {
- switch(i.customId) {
+ switch (i.customId) {
case "save": {
await i.deferUpdate();
await client.database.guilds.write(interaction.guild.id, { tickets: ticketData });
@@ -161,7 +170,7 @@
.setStyle(TextInputStyle.Short)
)
)
- )
+ );
await i.editReply({
embeds: [
new EmojiEmbed()
@@ -189,7 +198,7 @@
if (!out || out.isButton()) continue;
out = out as ModalSubmitInteraction;
const toAdd = out.fields.getTextInputValue("maxTickets");
- if(isNaN(parseInt(toAdd))) {
+ if (isNaN(parseInt(toAdd))) {
errorMessage = "You entered an invalid number - No changes were made";
break;
}
@@ -204,11 +213,9 @@
}
}
}
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
-
-
async function manageTypes(interaction: CommandInteraction, data: GuildConfig["tickets"], m: Message) {
let timedOut = false;
let backPressed = false;
@@ -278,7 +285,9 @@
new StringSelectMenuOptionBuilder({
label: capitalize(type),
value: type,
- emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")) as APIMessageComponentEmoji,
+ emoji: client.emojis.cache.get(
+ getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")
+ ) as APIMessageComponentEmoji,
default: inUse.includes(type)
})
);
@@ -325,7 +334,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -394,7 +409,7 @@
}
toAdd = toAdd.substring(0, 80);
try {
- if(!data.customTypes) data.customTypes = [];
+ if (!data.customTypes) data.customTypes = [];
data.customTypes.push(toAdd);
} catch {
continue;
diff --git a/src/commands/settings/tracks.ts b/src/commands/settings/tracks.ts
index 39efede..20972f4 100644
--- a/src/commands/settings/tracks.ts
+++ b/src/commands/settings/tracks.ts
@@ -1,4 +1,26 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, Collection, CommandInteraction, GuildMember, Message, ModalBuilder, ModalSubmitInteraction, PermissionsBitField, Role, RoleSelectMenuBuilder, RoleSelectMenuInteraction, SlashCommandSubcommandBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ Collection,
+ CommandInteraction,
+ GuildMember,
+ Message,
+ ModalBuilder,
+ ModalSubmitInteraction,
+ PermissionsBitField,
+ Role,
+ RoleSelectMenuBuilder,
+ RoleSelectMenuInteraction,
+ SlashCommandSubcommandBuilder,
+ StringSelectMenuBuilder,
+ StringSelectMenuInteraction,
+ StringSelectMenuOptionBuilder,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import client from "../../utils/client.js";
import createPageIndicator, { createVerticalTrack } from "../../utils/createPageIndicator.js";
import { LoadingEmbed } from "../../utils/defaults.js";
@@ -7,12 +29,10 @@
import ellipsis from "../../utils/ellipsis.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
-const { renderRole } = client.logger
+const { renderRole } = client.logger;
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("tracks")
- .setDescription("Manage the tracks for the server")
+ builder.setName("tracks").setDescription("Manage the tracks for the server");
interface ObjectSchema {
name: string;
@@ -22,35 +42,36 @@
manageableBy: string[];
}
-
-const editName = async (i: ButtonInteraction, interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, current?: string) => {
-
+const editName = async (
+ i: ButtonInteraction,
+ interaction: StringSelectMenuInteraction | ButtonInteraction,
+ m: Message,
+ current?: string
+) => {
let name = current ?? "";
const modal = new ModalBuilder()
.setTitle("Edit Name and Description")
.setCustomId("editNameDescription")
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setLabel("Name")
- .setCustomId("name")
- .setPlaceholder("The name of the track (e.g. Moderators)")
- .setStyle(TextInputStyle.Short)
- .setValue(name)
- .setRequired(true)
- )
- )
- const button = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setLabel("Name")
+ .setCustomId("name")
+ .setPlaceholder("The name of the track (e.g. Moderators)")
+ .setStyle(TextInputStyle.Short)
+ .setValue(name)
+ .setRequired(true)
+ )
+ );
+ const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
- await i.showModal(modal)
+ await i.showModal(modal);
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -63,41 +84,42 @@
let out: ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(m, interaction.user)) as ModalSubmitInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return name;
+ if (!out) return name;
if (out.isButton()) return name;
name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
- return name
+ return name;
+};
-}
-
-const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles: Collection<string, Role>, currentObj: string[]) => {
- const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("reorder")
- .setPlaceholder("Select all roles in the order you want users to gain them (Lowest to highest rank).")
- .setMinValues(currentObj.length)
- .setMaxValues(currentObj.length)
- .addOptions(
- currentObj.map((o, i) => new StringSelectMenuOptionBuilder()
- .setLabel(roles.get(o)!.name)
- .setValue(i.toString())
- )
+const reorderTracks = async (
+ interaction: ButtonInteraction,
+ m: Message,
+ roles: Collection<string, Role>,
+ currentObj: string[]
+) => {
+ const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("reorder")
+ .setPlaceholder("Select all roles in the order you want users to gain them (Lowest to highest rank).")
+ .setMinValues(currentObj.length)
+ .setMaxValues(currentObj.length)
+ .addOptions(
+ currentObj.map((o, i) =>
+ new StringSelectMenuOptionBuilder().setLabel(roles.get(o)!.name).setValue(i.toString())
)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ )
+ );
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -109,134 +131,154 @@
});
let out: StringSelectMenuInteraction | ButtonInteraction | null;
try {
- out = await m.awaitMessageComponent({
+ out = (await m.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
- }) as StringSelectMenuInteraction | ButtonInteraction | null;
+ })) as StringSelectMenuInteraction | ButtonInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return;
+ if (!out) return;
out.deferUpdate();
if (out.isButton()) return;
const values = out.values;
const newOrder: string[] = currentObj.map((_, i) => {
- const index = values.findIndex(v => v === i.toString());
+ const index = values.findIndex((v) => v === i.toString());
return currentObj[index];
}) as string[];
return newOrder;
-}
+};
-const editTrack = async (interaction: ButtonInteraction | StringSelectMenuInteraction, message: Message, roles: Collection<string, Role>, current?: ObjectSchema) => {
+const editTrack = async (
+ interaction: ButtonInteraction | StringSelectMenuInteraction,
+ message: Message,
+ roles: Collection<string, Role>,
+ current?: ObjectSchema
+) => {
const isAdmin = (interaction.member!.permissions as PermissionsBitField).has("Administrator");
- if(!current) {
+ if (!current) {
current = {
name: "",
retainPrevious: false,
nullable: false,
track: [],
manageableBy: []
- }
+ };
}
- const roleSelect = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("addRole")
- .setPlaceholder("Select a role to add")
- .setDisabled(!isAdmin)
- );
+ const roleSelect = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder().setCustomId("addRole").setPlaceholder("Select a role to add").setDisabled(!isAdmin)
+ );
let closed = false;
do {
- const editableRoles: string[] = current.track.map((r) => {
- if(!(roles.get(r)!.position >= (interaction.member as GuildMember).roles.highest.position) || interaction.user.id === interaction.guild?.ownerId) return roles.get(r)!.name;
- }).filter(v => v !== undefined) as string[];
- const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("removeRole")
- .setPlaceholder("Select a role to remove")
- .setDisabled(!isAdmin)
- .addOptions(
- editableRoles.map((r, i) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(r)
- .setValue(i.toString())}
- )
- )
- );
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("edit")
- .setLabel("Edit Name")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("reorder")
- .setLabel("Reorder")
- .setDisabled(!isAdmin)
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("retainPrevious")
- .setLabel("Retain Previous")
- .setStyle(current.retainPrevious ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("nullable")
- .setLabel(`Role ${current.nullable ? "Not " : ""}Required`)
- .setStyle(current.nullable ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji)
+ const editableRoles: string[] = current.track
+ .map((r) => {
+ if (
+ !(roles.get(r)!.position >= (interaction.member as GuildMember).roles.highest.position) ||
+ interaction.user.id === interaction.guild?.ownerId
+ )
+ return roles.get(r)!.name;
+ })
+ .filter((v) => v !== undefined) as string[];
+ const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("removeRole")
+ .setPlaceholder("Select a role to remove")
+ .setDisabled(!isAdmin)
+ .addOptions(
+ editableRoles.map((r, i) => {
+ return new StringSelectMenuOptionBuilder().setLabel(r).setValue(i.toString());
+ })
+ )
+ );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("edit")
+ .setLabel("Edit Name")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("reorder")
+ .setLabel("Reorder")
+ .setDisabled(!isAdmin)
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("retainPrevious")
+ .setLabel("Retain Previous")
+ .setStyle(current.retainPrevious ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName(
+ "CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"),
+ "id"
+ ) as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("nullable")
+ .setLabel(`Role ${current.nullable ? "Not " : ""}Required`)
+ .setStyle(current.nullable ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji
+ )
);
const allowed: boolean[] = [];
for (const role of current.track) {
const disabled: boolean =
roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position;
- allowed.push(disabled)
+ allowed.push(disabled);
}
- const mapped = current.track.map(role => roles.find(aRole => aRole.id === role)!);
+ const mapped = current.track.map((role) => roles.find((aRole) => aRole.id === role)!);
const embed = new EmojiEmbed()
.setTitle("Tracks")
.setDescription(
`**Currently Editing:** ${current.name}\n\n` +
- `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${current.nullable ? "don't " : ""}need a role in this track\n` +
- `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${current.retainPrevious ? "" : "don't "}keep all roles below their current highest\n\n` +
- createVerticalTrack(
- mapped.map(role => renderRole(role)), new Array(current.track.length).fill(false), allowed)
+ `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${
+ current.nullable ? "don't " : ""
+ }need a role in this track\n` +
+ `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${
+ current.retainPrevious ? "" : "don't "
+ }keep all roles below their current highest\n\n` +
+ createVerticalTrack(
+ mapped.map((role) => renderRole(role)),
+ new Array(current.track.length).fill(false),
+ allowed
+ )
)
- .setStatus("Success")
+ .setStatus("Success");
- const comps: ActionRowBuilder<RoleSelectMenuBuilder | ButtonBuilder | StringSelectMenuBuilder>[] = [roleSelect, buttons];
- if(current.track.length >= 1) comps.splice(1, 0, selectMenu);
+ const comps: ActionRowBuilder<RoleSelectMenuBuilder | ButtonBuilder | StringSelectMenuBuilder>[] = [
+ roleSelect,
+ buttons
+ ];
+ if (current.track.length >= 1) comps.splice(1, 0, selectMenu);
- interaction.editReply({embeds: [embed], components: comps});
+ interaction.editReply({ embeds: [embed], components: comps });
let out: ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
try {
- out = await message.awaitMessageComponent({
+ out = (await message.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
- }) as ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
+ })) as ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return;
+ if (!out) return;
if (out.isButton()) {
- switch(out.customId) {
+ switch (out.customId) {
case "back": {
out.deferUpdate();
closed = true;
@@ -264,34 +306,34 @@
}
} else if (out.isStringSelectMenu()) {
out.deferUpdate();
- switch(out.customId) {
+ switch (out.customId) {
case "removeRole": {
- const index = current.track.findIndex(v => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]);
+ const index = current.track.findIndex(
+ (v) => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]
+ );
current.track.splice(index, 1);
break;
}
}
} else {
- switch(out.customId) {
+ switch (out.customId) {
case "addRole": {
const role = out.values![0]!;
- if(!current.track.includes(role)) {
+ if (!current.track.includes(role)) {
current.track.push(role);
} else {
- out.reply({content: "That role is already on this track", ephemeral: true})
+ out.reply({ content: "That role is already on this track", ephemeral: true });
}
break;
}
}
}
-
- } while(!closed);
+ } while (!closed);
return current;
-}
+};
const callback = async (interaction: CommandInteraction) => {
-
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true})
+ const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
const config = await client.database.guilds.read(interaction.guild!.id);
const tracks: ObjectSchema[] = config.tracks;
const roles = await interaction.guild!.roles.fetch();
@@ -301,16 +343,11 @@
let modified = false;
do {
- const embed = new EmojiEmbed()
- .setTitle("Track Settings")
- .setEmoji("TRACKS.ICON")
- .setStatus("Success");
+ const embed = new EmojiEmbed().setTitle("Track Settings").setEmoji("TRACKS.ICON").setStatus("Success");
const noTracks = config.tracks.length === 0;
let current: ObjectSchema;
- const pageSelect = new StringSelectMenuBuilder()
- .setCustomId("page")
- .setPlaceholder("Select a track to manage");
+ const pageSelect = new StringSelectMenuBuilder().setCustomId("page").setPlaceholder("Select a track to manage");
const actionSelect = new StringSelectMenuBuilder()
.setCustomId("action")
.setPlaceholder("Perform an action")
@@ -325,51 +362,56 @@
.setDescription("Delete this track")
.setValue("delete")
.setEmoji(getEmojiByName("TICKETS.ISSUE", "id") as APIMessageComponentEmoji)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- .setDisabled(page === 0),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Primary)
- .setDisabled(page === tracks.length - 1),
- new ButtonBuilder()
- .setCustomId("add")
- .setLabel("New Track")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(Object.keys(tracks).length >= 24),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success)
- .setDisabled(!modified),
);
- if(noTracks) {
- embed.setDescription("No tracks have been set up yet. Use the button below to add one.\n\n" +
- createPageIndicator(1, 1, undefined, true)
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ .setDisabled(page === 0),
+ new ButtonBuilder()
+ .setCustomId("next")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(page === tracks.length - 1),
+ new ButtonBuilder()
+ .setCustomId("add")
+ .setLabel("New Track")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(tracks).length >= 24),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(!modified)
+ );
+ if (noTracks) {
+ embed.setDescription(
+ "No tracks have been set up yet. Use the button below to add one.\n\n" +
+ createPageIndicator(1, 1, undefined, true)
);
pageSelect.setDisabled(true);
actionSelect.setDisabled(true);
- pageSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel("No tracks")
- .setValue("none")
- );
+ pageSelect.addOptions(new StringSelectMenuOptionBuilder().setLabel("No tracks").setValue("none"));
} else {
page = Math.min(page, Object.keys(tracks).length - 1);
current = tracks[page]!;
- const mapped = current.track.map(role => roles.find(aRole => aRole.id === role)!);
- embed.setDescription(`**Currently Editing:** ${current.name}\n\n` +
- `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${current.nullable ? "don't " : ""}need a role in this track\n` +
- `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${current.retainPrevious ? "" : "don't "}keep all roles below their current highest\n\n` +
- createVerticalTrack(mapped.map(role => renderRole(role)), new Array(current.track.length).fill(false)) +
- `\n${createPageIndicator(config.tracks.length, page)}`
+ const mapped = current.track.map((role) => roles.find((aRole) => aRole.id === role)!);
+ embed.setDescription(
+ `**Currently Editing:** ${current.name}\n\n` +
+ `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${
+ current.nullable ? "don't " : ""
+ }need a role in this track\n` +
+ `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${
+ current.retainPrevious ? "" : "don't "
+ }keep all roles below their current highest\n\n` +
+ createVerticalTrack(
+ mapped.map((role) => renderRole(role)),
+ new Array(current.track.length).fill(false)
+ ) +
+ `\n${createPageIndicator(config.tracks.length, page)}`
);
pageSelect.addOptions(
@@ -380,13 +422,23 @@
.setValue(index.toString());
})
);
-
}
- await interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect), new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect), buttonRow]});
+ await interaction.editReply({
+ embeds: [embed],
+ components: [
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
+ buttonRow
+ ]
+ });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
closed = true;
continue;
@@ -404,14 +456,14 @@
break;
}
case "add": {
- const newPage = await editTrack(i, m, roles)
- if(!newPage) break;
+ const newPage = await editTrack(i, m, roles);
+ if (!newPage) break;
tracks.push();
page = tracks.length - 1;
break;
}
case "save": {
- client.database.guilds.write(interaction.guild!.id, {tracks: tracks});
+ client.database.guilds.write(interaction.guild!.id, { tracks: tracks });
modified = false;
await client.memory.forceUpdate(interaction.guild!.id);
break;
@@ -420,16 +472,16 @@
} else if (i.isStringSelectMenu()) {
switch (i.customId) {
case "action": {
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "edit": {
const edited = await editTrack(i, m, roles, current!);
- if(!edited) break;
+ if (!edited) break;
tracks[page] = edited;
modified = true;
break;
}
case "delete": {
- if(page === 0 && tracks.keys.length - 1 > 0) page++;
+ if (page === 0 && tracks.keys.length - 1 > 0) page++;
else page--;
tracks.splice(page, 1);
break;
@@ -443,10 +495,9 @@
}
}
}
-
} while (!closed);
- await interaction.deleteReply()
-}
+ await interaction.deleteReply();
+};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
const member = interaction.member as GuildMember;
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 9c091a1..e2318fc 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -16,10 +16,7 @@
import lodash from "lodash";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("verify")
- .setDescription("Manage the role given after a user runs /verify")
-
+ builder.setName("verify").setDescription("Manage the role given after a user runs /verify");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
@@ -33,33 +30,31 @@
let config = await client.database.guilds.read(interaction.guild.id);
let data = Object.assign({}, config.verify);
do {
- const selectMenu = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("role")
- .setPlaceholder("Select a role")
+ const selectMenu = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select a role")
);
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("switch")
- .setLabel(data.enabled ? "Enabled" : "Disabled")
- .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setDisabled(lodash.isEqual(config.verify, data))
- );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("switch")
+ .setLabel(data.enabled ? "Enabled" : "Disabled")
+ .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setDisabled(lodash.isEqual(config.verify, data))
+ );
const embed = new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(
`Select a role to be given to users after they run ${getCommandMentionByName("verify")}` +
- `\n\nCurrent role: ${config.verify.role ? `<@&${config.verify.role}>` : "None"}`
+ `\n\nCurrent role: ${config.verify.role ? `<@&${config.verify.role}>` : "None"}`
)
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE");
@@ -73,7 +68,9 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id }
+ filter: (i) => {
+ return i.user.id === interaction.user.id;
+ }
});
} catch (e) {
closed = true;
@@ -82,26 +79,25 @@
await i.deferUpdate();
- if(i.isButton()) {
+ if (i.isButton()) {
switch (i.customId) {
case "save": {
- client.database.guilds.write(interaction.guild.id, {"verify": data} )
+ client.database.guilds.write(interaction.guild.id, { verify: data });
config = await client.database.guilds.read(interaction.guild.id);
data = Object.assign({}, config.verify);
await client.memory.forceUpdate(interaction.guild.id);
- break
+ break;
}
case "switch": {
data.enabled = !data.enabled;
- break
+ break;
}
}
} else {
data.role = i.values[0]!;
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index b2d484c..bf52dd1 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -14,7 +14,7 @@
ModalBuilder,
TextInputBuilder,
TextInputStyle,
- ModalSubmitInteraction,
+ ModalSubmitInteraction
} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -24,9 +24,7 @@
import { modalInteractionCollector } from "../../utils/dualCollector.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("welcome")
- .setDescription("Messages and roles sent or given when someone joins the server")
+ builder.setName("welcome").setDescription("Messages and roles sent or given when someone joins the server");
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderChannel } = client.logger;
@@ -39,80 +37,87 @@
let config = await client.database.guilds.read(interaction.guild!.id);
let data = Object.assign({}, config.welcome);
do {
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("switch")
- .setLabel(data.enabled ? "Enabled" : "Disabled")
- .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("message")
- .setLabel((data.message ? "Change" : "Set") + "Message")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("channelDM")
- .setLabel("Send in DMs")
- .setStyle(ButtonStyle.Primary)
- .setDisabled(data.channel === "dm"),
- new ButtonBuilder()
- .setCustomId("role")
- .setLabel("Clear Role")
- .setStyle(ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setStyle(ButtonStyle.Success)
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setDisabled(
- data.enabled === config.welcome.enabled &&
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("switch")
+ .setLabel(data.enabled ? "Enabled" : "Disabled")
+ .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("message")
+ .setLabel((data.message ? "Change" : "Set") + "Message")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("channelDM")
+ .setLabel("Send in DMs")
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(data.channel === "dm"),
+ new ButtonBuilder()
+ .setCustomId("role")
+ .setLabel("Clear Role")
+ .setStyle(ButtonStyle.Danger)
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setDisabled(
+ data.enabled === config.welcome.enabled &&
data.message === config.welcome.message &&
data.role === config.welcome.role &&
data.ping === config.welcome.ping &&
data.channel === config.welcome.channel
- )
- );
+ )
+ );
- const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
- .addComponents(
- new ChannelSelectMenuBuilder()
- .setCustomId("channel")
- .setPlaceholder("Select a channel to send welcome messages to")
- );
- const roleMenu = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("roleToGive")
- .setPlaceholder("Select a role to give to the member when they join the server")
- );
- const pingMenu = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("roleToPing")
- .setPlaceholder("Select a role to ping when a member joins the server")
- );
+ const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+ new ChannelSelectMenuBuilder()
+ .setCustomId("channel")
+ .setPlaceholder("Select a channel to send welcome messages to")
+ );
+ const roleMenu = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder()
+ .setCustomId("roleToGive")
+ .setPlaceholder("Select a role to give to the member when they join the server")
+ );
+ const pingMenu = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder()
+ .setCustomId("roleToPing")
+ .setPlaceholder("Select a role to ping when a member joins the server")
+ );
const embed = new EmojiEmbed()
.setTitle("Welcome Settings")
.setStatus("Success")
.setDescription(
- `${getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Welcome messages and roles are ${data.enabled ? "enabled" : "disabled"}\n` +
- `**Welcome message:** ${data.message ?
- `\n> ` +
- await convertCurlyBracketString(
- data.message,
- interaction.user.id,
- interaction.user.username,
- interaction.guild!.name,
- interaction.guild!.members
- )
- : "*None*"}\n` +
- `**Send message in:** ` + (data.channel ? (data.channel == "dm" ? "DMs" : renderChannel(data.channel)) : `*None set*`) + `\n` +
- `**Role to ping:** ` + (data.ping ? `<@&${data.ping}>` : `*None set*`) + `\n` +
- `**Role given on join:** ` + (data.role ? `<@&${data.role}>` : `*None set*`)
- )
+ `${getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Welcome messages and roles are ${
+ data.enabled ? "enabled" : "disabled"
+ }\n` +
+ `**Welcome message:** ${
+ data.message
+ ? `\n> ` +
+ (await convertCurlyBracketString(
+ data.message,
+ interaction.user.id,
+ interaction.user.username,
+ interaction.guild!.name,
+ interaction.guild!.members
+ ))
+ : "*None*"
+ }\n` +
+ `**Send message in:** ` +
+ (data.channel ? (data.channel == "dm" ? "DMs" : renderChannel(data.channel)) : `*None set*`) +
+ `\n` +
+ `**Role to ping:** ` +
+ (data.ping ? `<@&${data.ping}>` : `*None set*`) +
+ `\n` +
+ `**Role given on join:** ` +
+ (data.role ? `<@&${data.role}>` : `*None set*`)
+ );
await interaction.editReply({
embeds: [embed],
@@ -121,17 +126,17 @@
let i: RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({
+ i = (await m.awaitMessageComponent({
filter: (interaction) => interaction.user.id === interaction.user.id,
time: 300000
- }) as RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
+ })) as RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
} catch (e) {
closed = true;
continue;
}
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "switch": {
await i.deferUpdate();
data.enabled = !data.enabled;
@@ -148,7 +153,7 @@
.setLabel("Server Info (1/3)")
.setPlaceholder(
`{serverName} - This server's name\n\n` +
- `These placeholders will be replaced with the server's name, etc..`
+ `These placeholders will be replaced with the server's name, etc..`
)
.setMaxLength(1)
.setRequired(false)
@@ -160,8 +165,8 @@
.setLabel("Member Counts (2/3) - {MemberCount:...}")
.setPlaceholder(
`{:all} - Total member count\n` +
- `{:humans} - Total non-bot users\n` +
- `{:bots} - Number of bots\n`
+ `{:humans} - Total non-bot users\n` +
+ `{:bots} - Number of bots\n`
)
.setMaxLength(1)
.setRequired(false)
@@ -171,32 +176,28 @@
new TextInputBuilder()
.setCustomId("ex3")
.setLabel("Member who joined (3/3) - {member:...}")
- .setPlaceholder(
- `{:name} - The members name\n`
- )
+ .setPlaceholder(`{:name} - The members name\n`)
.setMaxLength(1)
.setRequired(false)
.setStyle(TextInputStyle.Paragraph)
),
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setCustomId("message")
- .setPlaceholder("Enter a message to send when someone joins the server")
- .setValue(data.message ?? "")
- .setLabel("Message")
- .setStyle(TextInputStyle.Paragraph)
- )
- )
- const button = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
- await i.showModal(modal)
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("message")
+ .setPlaceholder("Enter a message to send when someone joins the server")
+ .setValue(data.message ?? "")
+ .setLabel("Message")
+ .setStyle(TextInputStyle.Paragraph)
+ )
+ );
+ const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
+ await i.showModal(modal);
await i.editReply({
embeds: [
new EmojiEmbed()
@@ -209,21 +210,21 @@
let out: ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(m, interaction.user)) as ModalSubmitInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) break;
+ if (!out) break;
data.message = out.fields.getTextInputValue("message");
break;
}
case "save": {
await i.deferUpdate();
- await client.database.guilds.write(interaction.guild!.id, {"welcome": data});
+ await client.database.guilds.write(interaction.guild!.id, { welcome: data });
config = await client.database.guilds.read(interaction.guild!.id);
data = Object.assign({}, config.welcome);
- await client.memory.forceUpdate(interaction.guild!.id)
+ await client.memory.forceUpdate(interaction.guild!.id);
break;
}
case "channelDM": {
@@ -239,23 +240,22 @@
}
} else if (i.isRoleSelectMenu()) {
await i.deferUpdate();
- switch(i.customId) {
+ switch (i.customId) {
case "roleToGive": {
data.role = i.values[0]!;
- break
+ break;
}
case "roleToPing": {
data.ping = i.values[0]!;
- break
+ break;
}
}
} else {
await i.deferUpdate();
data.channel = i.values[0]!;
}
-
} while (!closed);
- await interaction.deleteReply()
+ await interaction.deleteReply();
};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
@@ -266,16 +266,16 @@
};
const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
- const validReplacements = ["serverName", "memberCount:all", "memberCount:bots", "memberCount:humans"]
+ const validReplacements = ["serverName", "memberCount:all", "memberCount:bots", "memberCount:humans"];
if (!interaction.guild) return [];
const prompt = interaction.options.getString("message");
const autocompletions = [];
- if ( prompt === null ) {
+ if (prompt === null) {
for (const replacement of validReplacements) {
autocompletions.push(`{${replacement}}`);
- };
+ }
return autocompletions;
- };
+ }
const beforeLastOpenBracket = prompt.match(/(.*){[^{}]{0,15}$/);
const afterLastOpenBracket = prompt.match(/{[^{}]{0,15}$/);
if (beforeLastOpenBracket !== null) {
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 6ffecca..428a1f3 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,4 +1,11 @@
-import { AutocompleteInteraction, CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } from "discord.js";
+import {
+ AutocompleteInteraction,
+ CommandInteraction,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ SlashCommandBuilder
+} from "discord.js";
import client from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import { capitalize } from "../utils/generateKeyValueList.js";
@@ -32,14 +39,13 @@
if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
url = tag;
components = [
- new ActionRowBuilder<ButtonBuilder>().addComponents([new ButtonBuilder().setLabel("Open").setURL(url).setStyle(ButtonStyle.Link)])
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder().setLabel("Open").setURL(url).setStyle(ButtonStyle.Link)
+ ])
];
}
- const em = new EmojiEmbed()
- .setTitle(capitalize(search))
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setStatus("Success")
- if (url) em.setImage(url)
+ const em = new EmojiEmbed().setTitle(capitalize(search)).setEmoji("PUNISH.NICKNAME.GREEN").setStatus("Success");
+ if (url) em.setImage(url);
else em.setDescription(tag);
await interaction.reply({
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 7e297c8..04c68b5 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -100,7 +100,11 @@
toUnset.push(`tags.${name}`);
toSet[`tags.${newname}`] = data.tags[name]!;
}
- await client.database.guilds.write(interaction.guild.id, Object.keys(toSet).length === 0 ? null : toSet, toUnset);
+ await client.database.guilds.write(
+ interaction.guild.id,
+ Object.keys(toSet).length === 0 ? null : toSet,
+ toUnset
+ );
await client.memory.forceUpdate(interaction.guild!.id);
} catch (e) {
return await interaction.editReply({
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index dbb1200..ef365f9 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -15,8 +15,11 @@
import client from "../../utils/client.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import createPageIndicator from "../../utils/createPageIndicator.js";
-interface MessageSelectOptionData { label: string; value: string; description?: string; }
-
+interface MessageSelectOptionData {
+ label: string;
+ value: string;
+ description?: string;
+}
class Embed {
embed: Discord.EmbedBuilder = new EmbedBuilder();
@@ -139,7 +142,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -163,7 +172,9 @@
}
const em = new Discord.EmbedBuilder(pages[page]!.embed.data);
if (timedOut) {
- em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
+ em.setDescription(
+ em.data.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out"
+ );
} else {
em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
}
@@ -173,6 +184,5 @@
});
};
-
export { command };
export { callback };
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 2f3ddc6..b9a0dc6 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -14,6 +14,5 @@
await create(interaction);
};
-
export { command };
export { callback };
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 0eb8580..7e2902e 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -29,11 +29,15 @@
const guild = interaction.guild!;
const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember;
await userAbout(guild, member, interaction);
-}
+};
-async function userAbout(guild: Discord.Guild, member: Discord.GuildMember, interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction) {
- await member.user.fetch()
- await member.fetch()
+async function userAbout(
+ guild: Discord.Guild,
+ member: Discord.GuildMember,
+ interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction
+) {
+ await member.user.fetch();
+ await member.fetch();
await interaction.reply({
embeds: LoadingEmbed,
fetchReply: true,
@@ -59,10 +63,18 @@
) {
flags.push("CLICKSDEVELOPER");
}
- if (member.user.flags) { member.user.flags.toArray().map((flag) => { flags.push(flag.toString()); }); }
- if (member.user.bot) { flags.push("BOT"); }
+ if (member.user.flags) {
+ member.user.flags.toArray().map((flag) => {
+ flags.push(flag.toString());
+ });
+ }
+ if (member.user.bot) {
+ flags.push("BOT");
+ }
// Check if they are boosting the server
- if (member.premiumSince) { flags.push("BOOSTER"); }
+ if (member.premiumSince) {
+ flags.push("BOOSTER");
+ }
const nameReplacements: Record<string, string> = {
NUCLEUSDEVELOPER: "**Nucleus Developer**",
CLICKSDEVELOPER: "Clicks Developer",
@@ -79,7 +91,8 @@
Staff: "Discord Staff",
VerifiedDeveloper: "Verified Bot Developer",
ActiveDeveloper: "Active Developer",
- Quarantined: "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
+ Quarantined:
+ "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
Spammer: "Likely Spammer"
// CertifiedModerator
// VerifiedBot
@@ -139,24 +152,27 @@
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
.setDescription(
- flags.map((flag) => {
- if (nameReplacements[flag]) {
- const emoji = getEmojiByName(`BADGES.${flag}`)
- if (emoji) return (emoji + " " + nameReplacements[flag] + "\n");
- else return nameReplacements[flag] + "\n";
- }
- }).join("") + "\n" +
- generateKeyValueList({
- member: renderUser(member.user),
- nickname: member.nickname ?? "*None set*",
- id: `\`${member.id}\``,
- "joined the server": renderDelta(member.joinedTimestamp!),
- "joined discord": renderDelta(member.user.createdTimestamp),
- "boost status": member.premiumSince
- ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
- : "*Not boosting*",
- "join position": `${joinPos + 1}`
- })
+ flags
+ .map((flag) => {
+ if (nameReplacements[flag]) {
+ const emoji = getEmojiByName(`BADGES.${flag}`);
+ if (emoji) return emoji + " " + nameReplacements[flag] + "\n";
+ else return nameReplacements[flag] + "\n";
+ }
+ })
+ .join("") +
+ "\n" +
+ generateKeyValueList({
+ member: renderUser(member.user),
+ nickname: member.nickname ?? "*None set*",
+ id: `\`${member.id}\``,
+ "joined the server": renderDelta(member.joinedTimestamp!),
+ "joined discord": renderDelta(member.user.createdTimestamp),
+ "boost status": member.premiumSince
+ ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
+ : "*Not boosting*",
+ "join position": `${joinPos + 1}`
+ })
)
.setThumbnail(member.user.displayAvatarURL())
)
@@ -174,7 +190,10 @@
member: renderUser(member.user),
id: `\`${member.id}\``,
roles: `${member.roles.cache.size - 1}`
- }) + "\n" + (s.length > 0 ? s : "*None*") + "\n"
+ }) +
+ "\n" +
+ (s.length > 0 ? s : "*None*") +
+ "\n"
)
)
.setTitle("Roles")
@@ -199,7 +218,9 @@
.setDescription("Key permissions the user has")
.setPageId(2)
];
- if (member.user.bannerURL() ) { embeds[0]!.embed.setImage(member.user.bannerURL()!); }
+ if (member.user.bannerURL()) {
+ embeds[0]!.embed.setImage(member.user.bannerURL()!);
+ }
let page = 0;
let timedOut = false;
for (const embed of embeds) {
@@ -255,7 +276,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch {
timedOut = true;
@@ -281,8 +308,8 @@
embeds: [em],
components: []
});
-};
+}
export { command };
export { callback };
-export { userAbout };
\ No newline at end of file
+export { userAbout };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index da33f51..6804695 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -35,6 +35,5 @@
});
};
-
export { command };
export { callback };
diff --git a/src/commands/user/role.ts b/src/commands/user/role.ts
index 41820ac..74b6c41 100644
--- a/src/commands/user/role.ts
+++ b/src/commands/user/role.ts
@@ -1,17 +1,29 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, GuildMember, Role, RoleSelectMenuBuilder, RoleSelectMenuInteraction, UserSelectMenuBuilder, UserSelectMenuInteraction } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ CommandInteraction,
+ GuildMember,
+ Role,
+ RoleSelectMenuBuilder,
+ RoleSelectMenuInteraction,
+ UserSelectMenuBuilder,
+ UserSelectMenuInteraction
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../utils/client.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { LoadingEmbed } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import listToAndMore from "../../utils/listToAndMore.js"
+import listToAndMore from "../../utils/listToAndMore.js";
const { renderUser } = client.logger;
const canEdit = (role: Role, member: GuildMember, me: GuildMember): [string, boolean] => {
- if(role.position >= me.roles.highest.position ||
- role.position >= member.roles.highest.position
- ) return [`~~<@&${role.id}>~~`, false];
+ if (role.position >= me.roles.highest.position || role.position >= member.roles.highest.position)
+ return [`~~<@&${role.id}>~~`, false];
return [`<@&${role.id}>`, true];
};
@@ -19,103 +31,116 @@
builder
.setName("role")
.setDescription("Gives or removes a role from someone")
- .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"))
+ .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"));
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
let member = interaction.options.getMember("user") as GuildMember | null;
- if(!member) {
+ if (!member) {
const memberEmbed = new EmojiEmbed()
.setTitle("Role")
.setDescription(`Please choose a member to edit the roles of.`)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success");
const memberChooser = new ActionRowBuilder<UserSelectMenuBuilder>().addComponents(
- new UserSelectMenuBuilder()
- .setCustomId("memberChooser")
- .setPlaceholder("Select a member")
+ new UserSelectMenuBuilder().setCustomId("memberChooser").setPlaceholder("Select a member")
);
- await interaction.editReply({embeds: [memberEmbed], components: [memberChooser]});
+ await interaction.editReply({ embeds: [memberEmbed], components: [memberChooser] });
- const filter = (i: UserSelectMenuInteraction) => i.customId === "memberChooser" && i.user.id === interaction.user.id;
+ const filter = (i: UserSelectMenuInteraction) =>
+ i.customId === "memberChooser" && i.user.id === interaction.user.id;
let i: UserSelectMenuInteraction | null;
try {
- i = await m.awaitMessageComponent<5>({ filter, time: 300000});
+ i = await m.awaitMessageComponent<5>({ filter, time: 300000 });
} catch (e) {
return;
}
memberEmbed.setDescription(`Editing roles for ${renderUser(i.values[0]!)}`);
await i.deferUpdate();
- await interaction.editReply({ embeds: LoadingEmbed, components: [] })
+ await interaction.editReply({ embeds: LoadingEmbed, components: [] });
member = await interaction.guild?.members.fetch(i.values[0]!)!;
-
}
let closed = false;
let rolesToChange: string[] = [];
- const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("roleAdd")
- .setPlaceholder("Select a role to add")
- .setMaxValues(25)
- );
+ const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder().setCustomId("roleAdd").setPlaceholder("Select a role to add").setMaxValues(25)
+ );
do {
-
- const removing = rolesToChange.filter((r) => member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
- const adding = rolesToChange.filter((r) => !member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
- const embed = new EmojiEmbed()
- .setTitle("Role")
- .setDescription(
- `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
- `Adding:\n` +
- `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
- `Removing:\n` +
- `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
- )
- .setEmoji("GUILD.ROLES.CREATE")
- .setStatus("Success");
-
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("roleSave")
- .setLabel("Apply")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success),
- new ButtonBuilder()
- .setCustomId("roleDiscard")
- .setLabel("Reset")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Danger)
+ const removing = rolesToChange
+ .filter((r) => member!.roles.cache.has(r))
+ .map(
+ (r) =>
+ canEdit(
+ interaction.guild?.roles.cache.get(r)!,
+ interaction.member as GuildMember,
+ interaction.guild?.members.me!
+ )[0]
);
+ const adding = rolesToChange
+ .filter((r) => !member!.roles.cache.has(r))
+ .map(
+ (r) =>
+ canEdit(
+ interaction.guild?.roles.cache.get(r)!,
+ interaction.member as GuildMember,
+ interaction.guild?.members.me!
+ )[0]
+ );
+ const embed = new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription(
+ `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
+ `Adding:\n` +
+ `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
+ `Removing:\n` +
+ `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
+ )
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setStatus("Success");
+
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("roleSave")
+ .setLabel("Apply")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success),
+ new ButtonBuilder()
+ .setCustomId("roleDiscard")
+ .setLabel("Reset")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Danger)
+ );
await interaction.editReply({ embeds: [embed], components: [roleAdd, buttons] });
let i: RoleSelectMenuInteraction | ButtonInteraction | null;
try {
- i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 }) as RoleSelectMenuInteraction | ButtonInteraction;
+ i = (await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 })) as
+ | RoleSelectMenuInteraction
+ | ButtonInteraction;
} catch (e) {
closed = true;
continue;
}
i.deferUpdate();
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "roleSave": {
const roles = rolesToChange.map((r) => interaction.guild?.roles.cache.get(r)!);
await interaction.editReply({ embeds: LoadingEmbed, components: [] });
const rolesToAdd: Role[] = [];
const rolesToRemove: Role[] = [];
- for(const role of roles) {
- if(!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1]) continue;
- if(member.roles.cache.has(role.id)) {
+ for (const role of roles) {
+ if (!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1])
+ continue;
+ if (member.roles.cache.has(role.id)) {
rolesToRemove.push(role);
} else {
rolesToAdd.push(role);
@@ -135,9 +160,7 @@
} else {
rolesToChange = i.values;
}
-
} while (!closed);
-
};
const check = (interaction: CommandInteraction, partial: boolean = false) => {
@@ -145,7 +168,7 @@
// Check if the user has manage_roles permission
if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
if (partial) return true;
- if (!interaction.guild) return
+ if (!interaction.guild) return;
const me = interaction.guild.members.me!;
// Check if Nucleus has permission to role
if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index c7f441f..19b9da2 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,5 +1,17 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, GuildMember, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, APIMessageComponentEmoji, StringSelectMenuBuilder, MessageComponentInteraction, StringSelectMenuInteraction, StringSelectMenuOptionBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ APIMessageComponentEmoji,
+ StringSelectMenuBuilder,
+ MessageComponentInteraction,
+ StringSelectMenuInteraction,
+ StringSelectMenuOptionBuilder
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -14,7 +26,7 @@
.addUserOption((option) => option.setName("user").setDescription("The user to manage").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const { renderUser, renderRole} = client.logger;
+ const { renderUser, renderRole } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
if (!guild) return;
@@ -63,13 +75,15 @@
for (const role of data.track) {
const disabled: boolean =
roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position && !managed;
- allowed.push(!disabled)
+ allowed.push(!disabled);
}
- generated += "\n" + createVerticalTrack(
- data.track.map((role) => renderRole(roles.get(role)!)),
- data.track.map((role) => memberRoles.cache.has(role)),
- allowed.map((allow) => !allow)
- );
+ generated +=
+ "\n" +
+ createVerticalTrack(
+ data.track.map((role) => renderRole(roles.get(role)!)),
+ data.track.map((role) => memberRoles.cache.has(role)),
+ allowed.map((allow) => !allow)
+ );
const selected = [];
for (const position of data.track) {
if (memberRoles.cache.has(position)) selected.push(position);
@@ -117,7 +131,9 @@
],
components: [new ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>().addComponents(dropdown)]
.concat(
- conflict && conflictDropdown.length ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)] : []
+ conflict && conflictDropdown.length
+ ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)]
+ : []
)
.concat([
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -150,7 +166,13 @@
try {
component = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -158,7 +180,9 @@
}
component.deferUpdate();
if (component.customId === "conflict") {
- const rolesToRemove = selected.filter((role) => role !== (component as StringSelectMenuInteraction).values[0]);
+ const rolesToRemove = selected.filter(
+ (role) => role !== (component as StringSelectMenuInteraction).values[0]
+ );
await member.roles.remove(rolesToRemove);
} else if (component.customId === "promote") {
if (
@@ -196,7 +220,7 @@
if (member.id === interaction.guild!.ownerId) return true;
// Check if the user can manage any of the tracks
let managed = false;
- const memberRoles = member.roles.cache.map((r) => r.id)
+ const memberRoles = member.roles.cache.map((r) => r.id);
for (const element of tracks) {
if (!element.manageableBy.length) continue;
if (!element.manageableBy.some((role: string) => memberRoles.includes(role))) continue;