intermediate update
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index 7056fe6..31a9fcf 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -75,7 +75,7 @@
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let valid = false;
while (!valid) {
- itt += 1;
+ itt ++;
code = "";
for (let i = 0; i < length; i++) {
code += chars.charAt(Math.floor(Math.random() * chars.length));
@@ -83,7 +83,7 @@
if (code in client.roleMenu) continue;
if (itt > 1000) {
itt = 0;
- length += 1;
+ length ++;
continue;
}
valid = true;
diff --git a/src/commands/mod/about.ts b/src/commands/mod/about.ts
index 130cdbc..1f53afb 100644
--- a/src/commands/mod/about.ts
+++ b/src/commands/mod/about.ts
@@ -12,6 +12,7 @@
ButtonStyle,
StringSelectMenuInteraction,
TextInputStyle,
+ APIMessageComponentEmoji,
} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -167,8 +168,7 @@
.setLabel(value.text)
.setValue(key)
.setDefault(filteredTypes.includes(key))
- // @ts-expect-error
- .setEmoji(getEmojiByName(value.emoji, "id")) // FIXME: This gives a type error but is valid
+ .setEmoji(getEmojiByName(value.emoji, "id") as APIMessageComponentEmoji)
)))
]);
components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
@@ -270,8 +270,8 @@
continue;
}
i.deferUpdate();
- if (i.customId === "filter") {
- filteredTypes = (i as StringSelectMenuInteraction).values;
+ if (i.customId === "filter" && i.isStringSelectMenu()) {
+ filteredTypes = i.values;
pageIndex = null;
refresh = true;
}
@@ -412,7 +412,7 @@
timedOut = true;
continue;
}
- if (out === null) {
+ if (out === null || out.isButton()) {
continue;
} else if (out instanceof ModalSubmitInteraction) {
let toAdd = out.fields.getTextInputValue("note") || null;
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index b176dd4..4b6899c 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -7,7 +7,8 @@
ButtonStyle,
NonThreadGuildBasedChannel,
StringSelectMenuOptionBuilder,
- StringSelectMenuBuilder
+ StringSelectMenuBuilder,
+ APIMessageComponentEmoji
} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import type { GuildBasedChannel } from "discord.js";
@@ -126,8 +127,7 @@
return new StringSelectMenuOptionBuilder()
.setLabel(c)
.setValue((set * 25 + i).toString())
- // @ts-expect-error
- .setEmoji(getEmojiByName("ICONS.CHANNEL.CATEGORY", "id")) // Again, this is valid but TS doesn't think so
+ .setEmoji(getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji) // Again, this is valid but TS doesn't think so
.setDefault((set * 25 + i) === page)
}))
)}
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index d8b2807..8330fbe 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -13,7 +13,7 @@
.setTitle("Stats")
.setDescription(`**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``)
.setStatus("Success")
- .setEmoji("GUILD.GRAPHS")
+ .setEmoji("SETTINGS.STATS.GREEN")
],
ephemeral: true
});
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 25034b2..5cafcc5 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -191,7 +191,7 @@
} catch (e) {
continue;
}
- if (!out) 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;
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 6fb2461..e9e8dce 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -158,7 +158,7 @@
}
i.deferUpdate();
if ((i.component as unknown as ButtonInteraction).customId === "clear") {
- clicks += 1;
+ clicks ++;
if (clicks === 2) {
clicks = 0;
await client.database.guilds.write(interaction.guild!.id, null, ["logging.announcements.channel"]);
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 9b594e8..0852e67 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -151,7 +151,7 @@
i = i!
i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
- clicks += 1;
+ clicks ++;
if (clicks === 2) {
clicks = 0;
await client.database.guilds.write(interaction.guild!.id, null, ["logging.logs.channel"]);
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index fbe79fa..7332c7b 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -83,8 +83,8 @@
continue;
}
i.deferUpdate();
- if (i.customId === "logs") {
- const selected = (i as StringSelectMenuInteraction).values;
+ if (i.isStringSelectMenu() && i.customId === "logs") {
+ const selected = i.values;
const newLogs = toHexInteger(selected.map((e: string) => Object.keys(logs)[parseInt(e)]!));
await client.database.guilds.write(interaction.guild!.id, {
"logging.logs.toLog": newLogs
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 3a0f395..d6379f0 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -155,7 +155,7 @@
}
i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
- clicks += 1;
+ clicks ++;
if (clicks === 2) {
clicks = 0;
await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"]);
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 1093bd2..df99510 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,45 +1,283 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, Message, ActionRowBuilder, GuildMember, StringSelectMenuBuilder, StringSelectMenuInteraction, SelectMenuOptionBuilder } from "discord.js";
+import Discord, { CommandInteraction, Message, ActionRowBuilder, StringSelectMenuBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuOptionBuilder, APIMessageComponentEmoji, MessageComponentInteraction, TextInputBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import client from "../../utils/client.js";
import convertCurlyBracketString from "../../utils/convertCurlyBracketString.js";
import { callback as statsChannelAddCallback } from "../../reflex/statsChannelUpdate.js";
import singleNotify from "../../utils/singleNotify.js";
+import getEmojiByName from "../../utils/getEmojiByName.js";
+import createPageIndicator from "../../utils/createPageIndicator.js";
+import { modalInteractionCollector } from "../../utils/dualCollector.js";
+import type { GuildConfig } from "../../utils/database.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("stats")
.setDescription("Controls channels which update when someone joins or leaves the server")
+type ChangesType = Record<string, { name?: string; enabled?: boolean; }>
+
+const applyChanges = (baseObject: GuildConfig['stats'], changes: ChangesType): GuildConfig['stats'] => {
+ for (const [id, { name, enabled }] of Object.entries(changes)) {
+ if (!baseObject[id]) baseObject[id] = { name: "", enabled: false};
+ if (name) baseObject[id]!.name = name;
+ if (enabled) baseObject[id]!.enabled = enabled;
+ }
+ return baseObject;
+}
+
+
const callback = async (interaction: CommandInteraction) => {
+ try{
if (!interaction.guild) return;
+ const { renderChannel } = client.logger;
let closed = false;
let page = 0;
+ const m: Message = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
+ let changes: ChangesType = {};
do {
const config = await client.database.guilds.read(interaction.guild.id);
- const stats = config.stats; // stats: Record<string, { name: string; enabled: boolean }>
- if (!stats) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Stats channels")
- .setDescription("You don't have ant stats channels yet")
- .setStatus("Success")
- .setEmoji("")
- ]})
- }
+ const stats = config.stats;
+ let currentID = "";
+ let current: {
+ name: string;
+ enabled: boolean;
+ } = {
+ name: "",
+ enabled: false
+ };
+ let description = "";
let pageSelect = new StringSelectMenuBuilder()
.setCustomId("page")
.setPlaceholder("Select a stats channel to manage")
+ .setDisabled(Object.keys(stats).length === 0)
.setMinValues(1)
.setMaxValues(1);
- for (const [id, { name, enabled }] of Object.entries(stats)) {
- pageSelect.addOption()
+ let actionSelect = new StringSelectMenuBuilder()
+ .setCustomId("action")
+ .setPlaceholder("Perform an action")
+ .setMinValues(1)
+ .setMaxValues(1)
+ .setDisabled(Object.keys(stats).length === 0)
+ .addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Edit")
+ .setValue("edit")
+ .setDescription("Edit the name of this stats channel")
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+ new StringSelectMenuOptionBuilder()
+ .setLabel("Delete")
+ .setValue("delete")
+ .setDescription("Delete this stats channel")
+ .setEmoji(getEmojiByName("TICKETS.ISSUE", "id") as APIMessageComponentEmoji)
+ );
+ if (Object.keys(stats).length === 0) {
+ description = "You do not have any stats channels set up yet"
+ pageSelect.addOptions(new StringSelectMenuOptionBuilder().setLabel("No stats channels").setValue("none"))
+ } else {
+ currentID = Object.keys(stats)[page]!
+ current = stats[currentID]!;
+ current = applyChanges({ [currentID]: current }, changes)[currentID]!;
+ // Propogate pageSelect with list of stats channels
+ for (const [id, { name, enabled }] of Object.entries(stats)) {
+ pageSelect.addOptions(
+ new StringSelectMenuOptionBuilder()
+ .setLabel(name)
+ .setValue(id)
+ .setDescription(`Enabled: ${enabled}`)
+ );
+ }
+ 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)
+ );
+ description = `**Currently Editing:** ${renderChannel(currentID)}\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)}`
}
- // [ Action... ] -> Edit, delete, reorder
- // [Back][Next][Add]
+ const row = 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(stats).length - 1),
+ new ButtonBuilder()
+ .setCustomId("add")
+ .setLabel("Create new")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(stats).length >= 24),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(Object.keys(changes).length === 0),
+ );
+
+ let embed = new EmojiEmbed()
+ .setTitle("Stats Channels")
+ .setDescription(description + "\n\n" + createPageIndicator(Object.keys(stats).length, page))
+ .setEmoji("SETTINGS.STATS.GREEN")
+ .setStatus("Success")
+
+ interaction.editReply({
+ embeds: [embed],
+ components: [
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
+ row
+ ]
+ });
+ let i: MessageComponentInteraction;
+ try {
+ i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 30000 });
+ } catch (e) {
+ closed = true;
+ continue;
+ }
+ if (i.isStringSelectMenu()) {
+ switch(i.customId) {
+ case "page":
+ page = Object.keys(stats).indexOf(i.values[0]!);
+ i.deferUpdate();
+ break;
+ case "action":
+ if(!changes[currentID]) changes[currentID] = {};
+ switch(i.values[0]!) {
+ case "edit":
+ await i.showModal(
+ new Discord.ModalBuilder()
+ .setCustomId("modal")
+ .setTitle(`Stats channel name`)
+ .addComponents(
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("ex1")
+ .setLabel("Server Info (1/3)")
+ .setPlaceholder(
+ `{serverName} - This server's name\n\n` +
+ `These placeholders will be replaced with the server's name, etc..`
+ )
+ .setMaxLength(1)
+ .setRequired(false)
+ .setStyle(Discord.TextInputStyle.Paragraph)
+ ),
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("ex2")
+ .setLabel("Member Counts (2/3) - {MemberCount:...}")
+ .setPlaceholder(
+ `{:all} - Total member count\n` +
+ `{:humans} - Total non-bot users\n` +
+ `{:bots} - Number of bots\n`
+ )
+ .setMaxLength(1)
+ .setRequired(false)
+ .setStyle(Discord.TextInputStyle.Paragraph)
+ ),
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("ex3")
+ .setLabel("Latest Member (3/3) - {member:...}")
+ .setPlaceholder(
+ `{:name} - The members name\n`
+ )
+ .setMaxLength(1)
+ .setRequired(false)
+ .setStyle(Discord.TextInputStyle.Paragraph)
+ ),
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setCustomId("text")
+ .setLabel("Channel name input")
+ .setMaxLength(1000)
+ .setRequired(true)
+ .setStyle(Discord.TextInputStyle.Short)
+ .setValue(current.name)
+ )
+ )
+ );
+ 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")
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Primary)
+ .setCustomId("back")
+ )
+ ]
+ });
+ let out: Discord.ModalSubmitInteraction | null;
+ try {
+ out = await modalInteractionCollector(
+ m,
+ (m) => m.channel!.id === interaction.channel!.id,
+ (_) => true
+ ) as Discord.ModalSubmitInteraction | null;
+ } catch (e) {
+ continue;
+ }
+ if (!out) continue
+ if (!out.fields) continue
+ if (out.isButton()) continue;
+ const newString = out.fields.getTextInputValue("text");
+ if (!newString) continue;
+ changes[currentID]!.name = newString;
+ break;
+ case "delete":
+ changes[currentID] = {};
+ i.deferUpdate();
+ break;
+ case "toggleEnabled":
+ changes[currentID]!.enabled = !stats[currentID]!.enabled;
+ i.deferUpdate();
+ break;
+ }
+ break;
+ }
+ } else if (i.isButton()) {
+ i.deferUpdate();
+ switch(i.customId) {
+ case "back":
+ page--;
+ break;
+ case "next":
+ page++;
+ break;
+ case "add":
+ break;
+ case "save":
+ let changed = applyChanges(config.stats, changes);
+ singleNotify("statsChannelDeleted", interaction.guild.id, true)
+ config.stats = changed;
+ changes = {}
+ await client.database.guilds.write(interaction.guildId!, config);
+ }
+ }
+ console.log(changes, config.stats);
} while (!closed);
- closed = true;
+ } catch(e) {
+ console.log(e)
+ }
};
const check = (interaction: CommandInteraction) => {
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index aa25b69..8f9f688 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -11,11 +11,9 @@
MessageComponentInteraction,
StringSelectMenuBuilder,
Role,
- StringSelectMenuInteraction,
ButtonStyle,
TextInputBuilder,
ButtonComponent,
- StringSelectMenuComponent,
ModalSubmitInteraction,
APIMessageComponentEmoji
} from "discord.js";
@@ -390,14 +388,14 @@
innerTimedOut = true;
continue;
}
- if ((i.component as StringSelectMenuComponent).customId === "template") {
+ if (i.isStringSelectMenu() && i.customId === "template") {
i.deferUpdate();
await interaction.channel!.send({
embeds: [
new EmojiEmbed()
- .setTitle(ticketMessages[parseInt((i as StringSelectMenuInteraction).values[0]!)]!.label)
+ .setTitle(ticketMessages[parseInt(i.values[0]!)]!.label)
.setDescription(
- ticketMessages[parseInt((i as StringSelectMenuInteraction).values[0]!)]!.description
+ ticketMessages[parseInt(i.values[0]!)]!.description
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
@@ -643,16 +641,16 @@
timedOut = true;
continue;
}
- if ((i.component as StringSelectMenuComponent).customId === "types") {
+ if (i.isStringSelectMenu() && i.customId === "types") {
i.deferUpdate();
- const types = toHexInteger((i as StringSelectMenuInteraction).values, ticketTypes);
+ const types = toHexInteger(i.values, ticketTypes);
await client.database.guilds.write(interaction.guild!.id, {
"tickets.types": types
});
data.types = types;
- } else if ((i.component as StringSelectMenuComponent).customId === "removeTypes") {
+ } else if (i.isStringSelectMenu() && i.customId === "removeTypes") {
i.deferUpdate();
- const types = (i as StringSelectMenuInteraction).values;
+ const types = i.values;
let customTypes = data.customTypes;
if (customTypes) {
customTypes = customTypes.filter((t) => !types.includes(t));
@@ -708,6 +706,7 @@
} catch (e) {
continue;
}
+ if (!out || out.isButton()) continue;
out = out as ModalSubmitInteraction;
let toAdd = out.fields.getTextInputValue("type");
if (!toAdd) {
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 0f9f4a0..d3971a8 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -10,10 +10,8 @@
Role,
ButtonStyle,
StringSelectMenuBuilder,
- StringSelectMenuComponent,
TextInputBuilder,
EmbedBuilder,
- StringSelectMenuInteraction,
ButtonComponent
} from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -170,7 +168,7 @@
}
i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
- clicks += 1;
+ clicks ++;
if (clicks === 2) {
clicks = 0;
await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
@@ -257,14 +255,14 @@
innerTimedOut = true;
continue;
}
- if ((i.component as StringSelectMenuComponent).customId === "template") {
+ if (i.isStringSelectMenu() && i.customId === "template") {
i.deferUpdate();
await interaction.channel!.send({
embeds: [
new EmojiEmbed()
- .setTitle(verifyMessages[parseInt((i as StringSelectMenuInteraction).values[0]!)]!.label)
+ .setTitle(verifyMessages[parseInt(i.values[0]!)]!.label)
.setDescription(
- verifyMessages[parseInt((i as StringSelectMenuInteraction).values[0]!)]!.description
+ verifyMessages[parseInt(i.values[0]!)]!.description
)
.setStatus("Success")
.setEmoji("CONTROL.BLOCKTICK")
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 42376e8..abedec5 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -309,7 +309,7 @@
};
const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
- const validReplacements = ["serverName", "memberCount", "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 = [];
diff --git a/src/config/emojis.json b/src/config/emojis.json
index 26d4c98..8c45353 100644
--- a/src/config/emojis.json
+++ b/src/config/emojis.json
@@ -22,6 +22,7 @@
"FILTER": "990242059451514902",
"ATTACHMENT": "997570687193587812",
"LOGGING": "999613304446144562",
+ "SAVE": "1065722246322200586",
"NOTIFY": {
"ON": "1000726394579464232",
"OFF": "1000726363495477368"
@@ -210,6 +211,12 @@
"STOP": "853519660116738078"
}
},
+ "SETTINGS": {
+ "STATS": {
+ "GREEN": "752214059159650396",
+ "RED": "1065677252630675556"
+ }
+ },
"GUILD": {
"RED": "959779988264079361",
"YELLOW": "729763053352124529",
@@ -219,7 +226,6 @@
"EDIT": "729066518549233795",
"DELETE": "953035210121953320"
},
- "GRAPHS": "752214059159650396",
"SETTINGS": "752570111063228507",
"ICONCHANGE": "729763053612302356",
"TICKET": {
diff --git a/src/config/format.ts b/src/config/format.ts
index 929552f..b00b3e4 100644
--- a/src/config/format.ts
+++ b/src/config/format.ts
@@ -1,5 +1,4 @@
import fs from "fs";
-// @ts-expect-error
import * as readLine from "node:readline/promises";
const defaultDict: Record<string, string | string[] | boolean> = {
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 6829ef2..3971ad9 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -3,7 +3,6 @@
ActionRowBuilder,
ButtonBuilder,
MessageComponentInteraction,
- StringSelectMenuInteraction,
Guild,
CommandInteraction,
GuildTextBasedChannel,
@@ -285,8 +284,8 @@
selectPaneOpen = false;
} else if (i.component.customId === "select") {
selectPaneOpen = !selectPaneOpen;
- } else if (i.component.customId === "page") {
- page = parseInt((i as StringSelectMenuInteraction).values[0]!);
+ } else if (i.isStringSelectMenu() && i.component.customId === "page") {
+ page = parseInt(i.values[0]!);
selectPaneOpen = false;
} else {
cancelled = true;
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 573da5e..f7d0396 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -182,14 +182,14 @@
let itt = 0;
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
do {
- itt += 1;
+ itt ++;
code = "";
for (let i = 0; i < length; i++) {
code += chars.charAt(Math.floor(Math.random() * chars.length));
}
if (itt > 1000) {
itt = 0;
- length += 1;
+ length ++;
}
} while (code in verify);
const role: Role | null = await interaction.guild!.roles.fetch(config.verify.role);
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 4d90676..613b48c 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -257,7 +257,7 @@
cancelled = true;
continue;
}
- if (out === null) {
+ if (out === null || out.isButton()) {
cancelled = true;
continue;
}
diff --git a/src/utils/convertCurlyBracketString.ts b/src/utils/convertCurlyBracketString.ts
index 5d2c23d..058ba16 100644
--- a/src/utils/convertCurlyBracketString.ts
+++ b/src/utils/convertCurlyBracketString.ts
@@ -13,7 +13,7 @@
.replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}")
.replace("{member:name}", memberName ? `${memberName}` : "{member:name}")
.replace("{serverName}", serverName ? `${serverName}` : "{serverName}")
- .replace("{memberCount}", memberCount ? `${memberCount}` : "{memberCount}")
+ .replace("{memberCount:all}", memberCount ? `${memberCount}` : "{memberCount}")
.replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}")
.replace("{memberCount:humans}", memberCount && bots ? `${memberCount - bots}` : "{memberCount:humans}");
diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts
index 714a2d9..3c2b5d9 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -1,4 +1,4 @@
-import Discord, { Client, Interaction, Message, MessageComponentInteraction } from "discord.js";
+import Discord, { ButtonInteraction, Client, Interaction, InteractionCollector, Message, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
import client from "./client.js";
export default async function (
@@ -49,8 +49,8 @@
m: Message,
modalFilter: (i: Interaction) => boolean | Promise<boolean>,
interactionFilter: (i: MessageComponentInteraction) => boolean | Promise<boolean>
-): Promise<null | Interaction> {
- let out: Interaction;
+): Promise<null | ButtonInteraction | ModalSubmitInteraction> {
+ let out: ButtonInteraction | ModalSubmitInteraction;
try {
out = await new Promise((resolve, _reject) => {
const int = m
@@ -58,22 +58,17 @@
filter: (i: MessageComponentInteraction) => interactionFilter(i),
time: 300000
})
- .on("collect", (i: Interaction) => {
+ .on("collect", (i: ButtonInteraction) => {
+ mod.stop();
resolve(i);
});
- const mod = new Discord.InteractionCollector(client as Client, {
+ const mod = new InteractionCollector(client as Client, {
filter: (i: Interaction) => modalFilter(i),
time: 300000
- }).on("collect", async (i: Interaction) => {
+ }).on("collect", async (i: ModalSubmitInteraction) => {
int.stop();
- (i as Discord.ModalSubmitInteraction).deferUpdate();
- resolve(i as Discord.ModalSubmitInteraction);
- });
- int.on("end", () => {
- mod.stop();
- });
- mod.on("end", () => {
- int.stop();
+ await i.deferUpdate();
+ resolve(i);
});
});
} catch (e) {
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 54f656a..184f29a 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -29,7 +29,8 @@
if (typeof value === "number") value = value.toString();
return { value: value, displayValue: displayValue };
},
- renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel) {
+ renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel | string) {
+ if (typeof channel === "string") channel = client.channels.cache.get(channel) as Discord.GuildChannel | Discord.ThreadChannel;
return `${channel.name} [<#${channel.id}>]`;
},
renderRole(role: Discord.Role) {