diff --git a/src/commands/credits/index.ts b/src/commands/credits/index.ts index ad0f771..a1aaad6 100644 --- a/src/commands/credits/index.ts +++ b/src/commands/credits/index.ts @@ -2,34 +2,38 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../middlewares/logger"; -import modules from "./modules"; +// Modules +import moduleBalance from "./modules/balance"; +import moduleGift from "./modules/gift"; +import moduleTop from "./modules/top"; +import moduleWork from "./modules/work"; export const builder = new SlashCommandBuilder() .setName("credits") .setDescription("Manage your credits.") + .setDMPermission(false) - .addSubcommand(modules.balance.builder) - .addSubcommand(modules.gift.builder) - .addSubcommand(modules.top.builder) - .addSubcommand(modules.work.builder); - -export const moduleData = modules; + // Modules + .addSubcommand(moduleBalance.builder) + .addSubcommand(moduleGift.builder) + .addSubcommand(moduleTop.builder) + .addSubcommand(moduleWork.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; switch (options.getSubcommand()) { case "balance": - await modules.balance.execute(interaction); + await moduleBalance.execute(interaction); break; case "gift": - await modules.gift.execute(interaction); + await moduleGift.execute(interaction); break; case "top": - await modules.top.execute(interaction); + await moduleTop.execute(interaction); break; case "work": - await modules.work.execute(interaction); + await moduleWork.execute(interaction); break; default: logger.silly(`Unknown subcommand ${options.getSubcommand()}`); diff --git a/src/commands/credits/modules/balance/index.ts b/src/commands/credits/modules/balance/index.ts index a360c8e..9034f63 100644 --- a/src/commands/credits/modules/balance/index.ts +++ b/src/commands/credits/modules/balance/index.ts @@ -1,11 +1,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("balance") @@ -17,6 +17,8 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, true); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, user, guild } = interaction; diff --git a/src/commands/credits/modules/gift/index.ts b/src/commands/credits/modules/gift/index.ts index 4c2e541..db3435c 100644 --- a/src/commands/credits/modules/gift/index.ts +++ b/src/commands/credits/modules/gift/index.ts @@ -7,13 +7,12 @@ import { } from "discord.js"; import transferCredits from "../../../../helpers/transferCredits"; // Configurations +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; // Handlers // Function export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("gift") @@ -35,6 +34,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/credits/modules/index.ts b/src/commands/credits/modules/index.ts deleted file mode 100644 index 20edcaf..0000000 --- a/src/commands/credits/modules/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import balance from "./balance"; -import gift from "./gift"; -import top from "./top"; -import work from "./work"; - -export default { balance, gift, top, work }; diff --git a/src/commands/credits/modules/top/index.ts b/src/commands/credits/modules/top/index.ts index 7162744..075c599 100644 --- a/src/commands/credits/modules/top/index.ts +++ b/src/commands/credits/modules/top/index.ts @@ -2,6 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { GuildMember } from "@prisma/client"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; @@ -12,6 +13,8 @@ export default { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { guild } = interaction; diff --git a/src/commands/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts index 1a5407b..939ee06 100644 --- a/src/commands/credits/modules/work/index.ts +++ b/src/commands/credits/modules/work/index.ts @@ -9,15 +9,16 @@ import getEmbedConfig from "../../../../helpers/getEmbedData"; // Helpers // Handlers import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("work").setDescription(`Work to earn credits`); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, true); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure member