initial commit
Some checks failed
release-tag / release-image (push) Failing after 1m14s

This commit is contained in:
konchin
2024-10-11 19:49:58 +08:00
commit 2d7361e937
38 changed files with 4029 additions and 0 deletions

39
events/commands.ts Normal file
View File

@@ -0,0 +1,39 @@
import {Interaction} from 'discord.js';
import {isExtendedClient} from '../classes/extendedclient';
import {logger} from '../logger';
export async function handleCommands(interaction: Interaction): Promise<void>{
if(!interaction.isChatInputCommand()) return;
if(!isExtendedClient(interaction.client)){
logger.error(`Type Error in function "handleCommands"`);
return;
}
const command = interaction.client.commands.get(interaction.commandName);
if(!command){
logger.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try{
if('execute' in command)
await command.execute(interaction);
else{
logger.error('The command is missing a require "execute" function');
return;
}
}catch(error){
logger.error(`Execution error in function "handleCommands"`);
if(interaction.replied || interaction.deferred)
await interaction.followUp({
content: 'There was an error while executing this command!',
ephemeral: true
});
else
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}
}