From 5c97c21e2a120204d6806392f70a5aca381e17f6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:44:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Utility=20Command=20is=20now=20u?= =?UTF-8?q?sing=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/utility/index.ts | 24 ++++++++++++-------- src/commands/utility/modules/about/index.ts | 5 ++-- src/commands/utility/modules/avatar/index.ts | 5 ++-- src/commands/utility/modules/index.ts | 11 --------- src/commands/utility/modules/ping/index.ts | 5 ++-- src/commands/utility/modules/stats/index.ts | 5 ++-- 6 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 src/commands/utility/modules/index.ts diff --git a/src/commands/utility/index.ts b/src/commands/utility/index.ts index fb87528..a58d229 100644 --- a/src/commands/utility/index.ts +++ b/src/commands/utility/index.ts @@ -1,32 +1,36 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; -export const moduleData = modules; +// Modules +import moduleAbout from "./modules/about"; +import moduleAvatar from "./modules/avatar"; +import modulePing from "./modules/ping"; +import moduleStats from "./modules/stats"; export const builder = new SlashCommandBuilder() .setName("utility") .setDescription("Common utility.") - .addSubcommand(modules.about.builder) - .addSubcommand(modules.stats.builder) - .addSubcommand(modules.avatar.builder) - .addSubcommand(modules.ping.builder); + // Modules + .addSubcommand(moduleAbout.builder) + .addSubcommand(moduleStats.builder) + .addSubcommand(moduleAvatar.builder) + .addSubcommand(modulePing.builder); // Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": - await modules.about.execute(interaction); + await moduleAbout.execute(interaction); break; case "stats": - await modules.stats.execute(interaction); + await moduleStats.execute(interaction); break; case "avatar": - await modules.avatar.execute(interaction); + await moduleAvatar.execute(interaction); break; case "ping": - await modules.ping.execute(interaction); + await modulePing.execute(interaction); break; default: throw new Error( diff --git a/src/commands/utility/modules/about/index.ts b/src/commands/utility/modules/about/index.ts index 7265dad..01f0ad7 100644 --- a/src/commands/utility/modules/about/index.ts +++ b/src/commands/utility/modules/about/index.ts @@ -7,17 +7,18 @@ import { CommandInteraction, EmbedBuilder, } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; // Configurations import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("about").setDescription("About this bot!)"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/avatar/index.ts b/src/commands/utility/modules/avatar/index.ts index 1b87931..a6e4ffb 100644 --- a/src/commands/utility/modules/avatar/index.ts +++ b/src/commands/utility/modules/avatar/index.ts @@ -1,10 +1,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("avatar") @@ -16,6 +15,8 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/index.ts b/src/commands/utility/modules/index.ts deleted file mode 100644 index 7383403..0000000 --- a/src/commands/utility/modules/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import about from "./about"; -import avatar from "./avatar"; -import ping from "./ping"; -import stats from "./stats"; - -export default { - avatar, - about, - stats, - ping, -}; diff --git a/src/commands/utility/modules/ping/index.ts b/src/commands/utility/modules/ping/index.ts index 1442e03..3855e89 100644 --- a/src/commands/utility/modules/ping/index.ts +++ b/src/commands/utility/modules/ping/index.ts @@ -2,16 +2,17 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("ping").setDescription("Ping this bot"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/stats/index.ts b/src/commands/utility/modules/stats/index.ts index eae22f3..b422423 100644 --- a/src/commands/utility/modules/stats/index.ts +++ b/src/commands/utility/modules/stats/index.ts @@ -1,14 +1,15 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("stats").setDescription("Check bot statistics!)"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild );