🎨 Credits Command is now using guard classes
This commit is contained in:
parent
dd5ed64e1a
commit
be500e7f34
6 changed files with 27 additions and 22 deletions
|
@ -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()}`);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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 };
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue