djskage
Version:
A Discord.js extension for utility commands
23 lines (22 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const mockInteraction_1 = require("../utils/mockInteraction");
module.exports = {
name: "execute",
aliases: ["exec"],
description: "Execute a command as yourself, a different user in the current channel or a different channel.",
usage: "execute <command> [args?...] (?c <#id> -> channel, ?u <@id> -> user)",
execute: async (djskage, client, message) => {
const args = message.content.split(" ").slice(2);
if (!args.length)
return;
const guildCommands = await message.guild?.commands.fetch();
const globalCommands = await client.application?.commands.fetch();
const command = guildCommands?.find((cmd) => cmd.name === args[0]) ||
globalCommands?.find((cmd) => cmd.name === args[0]);
if (!command)
return message.reply(`Command "${args[0]}" not found.`);
const mockInteraction = new mockInteraction_1.Mockinteraction(client, message, command);
return client.emit("interactionCreate", mockInteraction);
},
};