Nucleus stats done / premium started
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 5cafcc5..f3a3538 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, Role, ButtonStyle, ButtonComponent, TextInputBuilder } from "discord.js";
+import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, Role, ButtonStyle, ButtonComponent, TextInputBuilder, Message } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -20,7 +20,7 @@
ephemeral: true,
fetchReply: true
});
- let m;
+ let m: Message;
let clicked = "";
if (interaction.options.get("role")) {
const confirmation = await new confirmationMessage(interaction)
@@ -110,7 +110,7 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
@@ -119,7 +119,7 @@
type modIDs = "mute" | "kick" | "ban" | "softban" | "warn" | "role";
let chosen = moderation[i.customId as modIDs];
if ((i.component as ButtonComponent).customId === "clearMuteRole") {
- i.deferUpdate();
+ await i.deferUpdate();
if (clicked === "clearMuteRole") {
await client.database.guilds.write(interaction.guild!.id, {
"moderation.mute.role": null
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index e9e8dce..f0ecbe9 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -150,13 +150,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if ((i.component as unknown as ButtonInteraction).customId === "clear") {
clicks ++;
if (clicks === 2) {
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 0852e67..b9b593c 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -143,13 +143,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
+ filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
}) as ButtonInteraction;
} catch (e) {
timedOut = true;
}
i = i!
- i.deferUpdate();
+ await i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
clicks ++;
if (clicks === 2) {
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 7332c7b..40b4607 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../../utils/defaults.js";
-import Discord, { CommandInteraction, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
+import Discord, { CommandInteraction, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder, StringSelectMenuOptionBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import client from "../../../utils/client.js";
@@ -76,13 +76,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if (i.isStringSelectMenu() && i.customId === "logs") {
const selected = i.values;
const newLogs = toHexInteger(selected.map((e: string) => Object.keys(logs)[parseInt(e)]!));
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index d6379f0..bba6441 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -147,13 +147,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
clicks ++;
if (clicks === 2) {
diff --git a/src/commands/settings/oldStats.ts b/src/commands/settings/oldStats.ts
index 475b5d3..457e705 100644
--- a/src/commands/settings/oldStats.ts
+++ b/src/commands/settings/oldStats.ts
@@ -139,7 +139,7 @@
});
let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.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;
@@ -148,7 +148,7 @@
switch(i.customId) {
case "page":
page = Object.keys(stats).indexOf(i.values[0]!);
- i.deferUpdate();
+ await i.deferUpdate();
break;
case "action":
if(!changes[currentID]) changes[currentID] = {};
@@ -243,17 +243,17 @@
break;
case "delete":
changes[currentID] = {};
- i.deferUpdate();
+ await i.deferUpdate();
break;
case "toggleEnabled":
changes[currentID]!.enabled = !stats[currentID]!.enabled;
- i.deferUpdate();
+ await i.deferUpdate();
break;
}
break;
}
} else if (i.isButton()) {
- i.deferUpdate();
+ await i.deferUpdate();
switch(i.customId) {
case "back":
page--;
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 7dd9cf4..2fd947b 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -73,23 +73,7 @@
type ObjectSchema = Record<string, {name: string, enabled: boolean}>
-/*
-let out: Discord.ModalSubmitInteraction | null = null;
-try {
- out = await modalInteractionCollector(
- m,
- (m) => m.channel!.id === interaction.channel!.id,
- (_) => true
- ) as Discord.ModalSubmitInteraction | null;
-} catch (e) {
- continue;
-}
-if (!out) continue
-out = out!;
-if (!out.fields) continue;
-if (out.isButton()) continue;
-const name = out.fields.getTextInputValue("text")
-*/
+
const addStatsChannel = async (interaction: CommandInteraction, m: Message, currentObject: ObjectSchema): Promise<ObjectSchema> => {
let closed = false;
@@ -99,7 +83,7 @@
let newChannelName: string = "{memberCount:all}-members";
let newChannelEnabled: boolean = true;
do {
- await interaction.editReply({
+ m = await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription(
@@ -114,6 +98,7 @@
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
new ChannelSelectMenuBuilder()
.setCustomId("channel")
+ .setPlaceholder("Select a channel to use")
),
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
@@ -141,7 +126,9 @@
});
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 }}) 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;
@@ -150,11 +137,11 @@
if (i.isButton()) {
switch (i.customId) {
case "back":
- if(!i.deferred) await i.deferUpdate();
+ await i.deferUpdate();
closed = true;
break;
case "save":
- if(!i.deferred) await i.deferUpdate(); //I'm lost...
+ await i.deferUpdate();
if (newChannel) {
currentObject[newChannel] = {
name: newChannelName,
@@ -185,8 +172,8 @@
const out = await modalInteractionCollector(
m,
- (m) => m.channel!.id === interaction.channel!.id,
- (_) => true
+ (m) => m.channel!.id === interaction.channel!.id && m.user!.id === interaction.user!.id,
+ (i) => i.channel!.id === interaction.channel!.id && i.user!.id === interaction.user!.id && i.message!.id === m.id
) as Discord.ModalSubmitInteraction | null;
if (!out) continue;
if (!out.fields) continue;
@@ -194,12 +181,12 @@
newChannelName = out.fields.getTextInputValue("text");
break;
case "toggleEnabled":
- if(!i.deferred) await i.deferUpdate();
+ await i.deferUpdate();
newChannelEnabled = !newChannelEnabled;
break;
}
} else {
- if(!i.deferred) await i.deferUpdate();
+ await i.deferUpdate();
if (i.customId === "channel") {
newChannel = i.values[0];
}
@@ -207,7 +194,7 @@
} while (!closed)
if (cancelled) return originalObject;
if (!(newChannel && newChannelName && newChannelEnabled)) return originalObject;
- return currentObject; // check 157
+ return currentObject;
}
const callback = async (interaction: CommandInteraction) => {
if (!interaction.guild) return;
@@ -322,6 +309,7 @@
if(i.isStringSelectMenu()) {
switch(i.customId) {
case "page":
+ await i.deferUpdate();
page = Object.keys(currentObject).indexOf(i.values[0]!);
break;
case "action":
@@ -364,14 +352,15 @@
break;
}
case "toggleEnabled": {
- i.deferUpdate();
+ await i.deferUpdate();
currentObject[Object.keys(currentObject)[page]!]!.enabled = !currentObject[Object.keys(currentObject)[page]!]!.enabled;
modified = true;
break;
}
case "delete": {
- i.deferUpdate();
+ await i.deferUpdate();
delete currentObject[Object.keys(currentObject)[page]!];
+ page = Math.min(page, Object.keys(currentObject).length - 1);
modified = true;
break;
}
@@ -379,7 +368,7 @@
break;
}
} else {
- i.deferUpdate();
+ await i.deferUpdate();
switch(i.customId) {
case "back":
page--;
@@ -389,6 +378,7 @@
break;
case "add":
currentObject = await addStatsChannel(interaction, m, currentObject);
+ page = Object.keys(currentObject).length - 1;
break;
case "save":
client.database.guilds.write(interaction.guild.id, {stats: currentObject});
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 8f9f688..6c74939 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -279,13 +279,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clearCategory") {
if (lastClicked === "cat") {
lastClicked = "";
@@ -382,14 +382,14 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
+ filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
});
} catch (e) {
innerTimedOut = true;
continue;
}
if (i.isStringSelectMenu() && i.customId === "template") {
- i.deferUpdate();
+ await i.deferUpdate();
await interaction.channel!.send({
embeds: [
new EmojiEmbed()
@@ -413,7 +413,7 @@
templateSelected = true;
continue;
} else if ((i.component as ButtonComponent).customId === "blank") {
- i.deferUpdate();
+ await i.deferUpdate();
await interaction.channel!.send({
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -635,21 +635,21 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
if (i.isStringSelectMenu() && i.customId === "types") {
- i.deferUpdate();
+ await i.deferUpdate();
const types = toHexInteger(i.values, ticketTypes);
await client.database.guilds.write(interaction.guild!.id, {
"tickets.types": types
});
data.types = types;
} else if (i.isStringSelectMenu() && i.customId === "removeTypes") {
- i.deferUpdate();
+ await i.deferUpdate();
const types = i.values;
let customTypes = data.customTypes;
if (customTypes) {
@@ -723,15 +723,15 @@
data.customTypes.push(toAdd);
}
} else if ((i.component as ButtonComponent).customId === "switchToDefault") {
- i.deferUpdate();
+ await i.deferUpdate();
await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": false }, []);
data.useCustom = false;
} else if ((i.component as ButtonComponent).customId === "switchToCustom") {
- i.deferUpdate();
+ await i.deferUpdate();
await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": true }, []);
data.useCustom = true;
} else {
- i.deferUpdate();
+ await i.deferUpdate();
backPressed = true;
}
}
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index d3971a8..23fc99b 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -160,13 +160,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if ((i.component as ButtonComponent).customId === "clear") {
clicks ++;
if (clicks === 2) {
@@ -249,14 +249,14 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
+ filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
});
} catch (e) {
innerTimedOut = true;
continue;
}
if (i.isStringSelectMenu() && i.customId === "template") {
- i.deferUpdate();
+ await i.deferUpdate();
await interaction.channel!.send({
embeds: [
new EmojiEmbed()
@@ -280,7 +280,7 @@
templateSelected = true;
continue;
} else if ((i.component as ButtonComponent).customId === "blank") {
- i.deferUpdate();
+ await i.deferUpdate();
await interaction.channel!.send({
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -375,7 +375,7 @@
}
}
} else {
- i.deferUpdate();
+ await i.deferUpdate();
break;
}
}
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index abedec5..fcd0f76 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -245,13 +245,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.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;
continue;
}
- i.deferUpdate();
+ await i.deferUpdate();
if (i.customId == "clear-message") {
if (lastClicked == "clear-message") {
await client.database.guilds.write(interaction.guild!.id, {