1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 16:30:59 -04:00
Daggerbot-TS/src/events/interactionCreate.ts

21 lines
1.3 KiB
TypeScript
Raw Normal View History

import Discord from 'discord.js';
2023-01-27 21:33:55 -05:00
import TClient from '../client';
export default {
2023-02-10 21:51:11 -05:00
async run(client:TClient, interaction:Discord.BaseInteraction){
2023-02-10 21:48:29 -05:00
if (!interaction.inGuild() || !interaction.inCachedGuild()) return;
2023-02-09 23:01:55 -05:00
if (interaction.isChatInputCommand()){
const commandFile = client.commands.get(interaction.commandName);
2023-02-09 23:01:55 -05:00
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''} in #${interaction.channel.name}`);
if (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true});
if (commandFile){
try{
commandFile.default.run(client, interaction);
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
2022-11-28 01:33:20 -05:00
} catch (error){
2022-11-24 19:28:46 -05:00
console.log(`An 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.');
}
}
}
}
}