Fix the admin dash's confirm as you can't show modals on deferred int… (#71)

…eractions
pull/75/head
Skyler 3 years ago committed by GitHub
commit 4365ae4b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,7 +22,7 @@ import config from "../../config/main.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("stats").setDescription("Gets the bot's stats"); builder.setName("stats").setDescription("Gets the bot's stats");
const confirm = async (interaction: CommandInteraction) => { const confirm = async (interaction: ButtonInteraction) => {
const requiredTexts = [ const requiredTexts = [
"just do it", "just do it",
"yes, do as i say!", "yes, do as i say!",
@ -189,8 +189,8 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
return; return;
} }
const guild = (await client.guilds.fetch(GuildID)) as Guild | null; const guild = (await client.guilds.fetch(GuildID)) as Guild | null;
await i.deferUpdate();
if (!guild) { if (!guild) {
await i.deferUpdate();
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [
new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger") new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")
@ -200,6 +200,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
return; return;
} }
if (i.customId === "stats") { if (i.customId === "stats") {
await i.deferUpdate();
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()
@ -218,7 +219,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
] ]
}); });
} else if (i.customId === "leave") { } else if (i.customId === "leave") {
if (!(await confirm(interaction))) { if (!(await confirm(i))) {
await interaction.editReply({ await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")],
components: [] components: []
@ -237,6 +238,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
components: [] components: []
}); });
} else if (i.customId === "data") { } else if (i.customId === "data") {
await i.deferUpdate();
// Get all the data and convert to a string // Get all the data and convert to a string
const data = await client.database.guilds.read(guild.id); const data = await client.database.guilds.read(guild.id);
const stringified = JSON.stringify(data, null, 2); const stringified = JSON.stringify(data, null, 2);
@ -253,7 +255,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
files: [attachment] files: [attachment]
}); });
} else if (i.customId === "purge") { } else if (i.customId === "purge") {
if (!(await confirm(interaction))) { if (!(await confirm(i))) {
await interaction.editReply({ await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")],
components: [] components: []
@ -275,6 +277,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
components: [] components: []
}); });
} else if (i.customId === "cache") { } else if (i.customId === "cache") {
await i.deferUpdate();
await client.memory.forceUpdate(guild.id); await client.memory.forceUpdate(guild.id);
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [

Loading…
Cancel
Save