🎨 Fun Command is now using guard classes

This commit is contained in:
Axel Olausson Holtenäs 2022-10-21 16:33:31 +02:00
parent f5c988b77b
commit cb19e0f788
3 changed files with 10 additions and 12 deletions

View file

@ -2,21 +2,20 @@ import { SlashCommandBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction } from "discord.js";
import logger from "../../middlewares/logger";
import modules from "./modules";
// Modules
import moduleMeme from "./modules/meme";
export const builder = new SlashCommandBuilder()
.setName("fun")
.setDescription("Fun commands.")
.addSubcommand(modules.meme.builder);
export const moduleData = modules;
.addSubcommand(moduleMeme.builder);
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
if (options.getSubcommand() === "meme") {
await modules.meme.execute(interaction);
await moduleMeme.execute(interaction);
} else {
logger.silly(`Unknown subcommand ${options.getSubcommand()}`);
}

View file

@ -1,5 +0,0 @@
import meme from "./meme";
export default {
meme,
};

View file

@ -1,16 +1,20 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import axios from "axios";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { command as CooldownCommand } from "../../../../handlers/cooldown";
import deferReply from "../../../../handlers/deferReply";
import getEmbedConfig from "../../../../helpers/getEmbedData";
export default {
metadata: { guildOnly: false, ephemeral: false, cooldown: 15 },
builder: (command: SlashCommandSubcommandBuilder) => {
return command.setName("meme").setDescription("Get a meme from r/memes)");
},
execute: async (interaction: CommandInteraction) => {
await deferReply(interaction, false);
await CooldownCommand(interaction, 15);
const { guild } = interaction;
const embedConfig = await getEmbedConfig(guild);