1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 00:31:00 -05:00
Daggerbot-TS/src/events/interactionCreate.ts

23 lines
1.4 KiB
TypeScript
Raw Normal View History

import Discord from 'discord.js';
import { TClient } from '../client';
export default {
name: 'interactionCreate',
execute: async(client:TClient, interaction:Discord.ChatInputCommandInteraction)=>{
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
if (interaction.isCommand()){
const commandFile = client.commands.get(interaction.commandName);
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName} in #${interaction.channel.name}`);
if (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Commands are currently disabled.', ephemeral: true});
if (commandFile){
if (commandFile.disabled) return interaction.reply({content: 'This command is currently disabled.', ephemeral: true});
try{
commandFile.default.run(client, interaction);
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
} catch (error:any){
console.log(`\x1b[31mAn error occured while running command "${commandFile.name}"`, error, error.stack);
2022-11-18 22:23:33 -05:00
return interaction.reply('An error occured while executing that command.');
}
}
}
}
}