🎨 DNS Commands is now using guard classes

This commit is contained in:
Axel Olausson Holtenäs 2022-10-21 16:18:00 +02:00
parent be500e7f34
commit f5c988b77b
3 changed files with 8 additions and 9 deletions

View file

@ -1,20 +1,21 @@
import { SlashCommandBuilder } from "@discordjs/builders"; import { SlashCommandBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } from "discord.js";
import modules from "./modules"; // Modules
export const moduleData = modules; import moduleLookup from "./modules/lookup";
export const builder = new SlashCommandBuilder() export const builder = new SlashCommandBuilder()
.setName("dns") .setName("dns")
.setDescription("DNS commands.") .setDescription("DNS commands.")
.addSubcommand(modules.lookup.builder); // Modules
.addSubcommand(moduleLookup.builder);
// Execute the command // Execute the command
export const execute = async (interaction: ChatInputCommandInteraction) => { export const execute = async (interaction: ChatInputCommandInteraction) => {
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case "lookup": case "lookup":
await modules.lookup.execute(interaction); await moduleLookup.execute(interaction);
break; break;
default: default:
throw new Error( throw new Error(

View file

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

View file

@ -1,11 +1,10 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import axios from "axios"; import axios from "axios";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import deferReply from "../../../../handlers/deferReply";
import getEmbedConfig from "../../../../helpers/getEmbedData"; import getEmbedConfig from "../../../../helpers/getEmbedData";
export default { export default {
metadata: { guildOnly: false, ephemeral: false },
builder: (command: SlashCommandSubcommandBuilder) => { builder: (command: SlashCommandSubcommandBuilder) => {
return command return command
.setName("lookup") .setName("lookup")
@ -20,6 +19,8 @@ export default {
); );
}, },
execute: async (interaction: ChatInputCommandInteraction) => { execute: async (interaction: ChatInputCommandInteraction) => {
await deferReply(interaction, false);
const { errorColor, successColor, footerText, footerIcon } = const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild); await getEmbedConfig(interaction.guild);
const embedTitle = "[:hammer:] Utility (Lookup)"; const embedTitle = "[:hammer:] Utility (Lookup)";