Haha-Yes/events/client/interactionCreate.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-08-14 22:29:19 +02:00
import db from '../../models/index.js';
2022-06-17 01:25:05 +02:00
export default {
name: 'interactionCreate',
async execute(interaction) {
const client = interaction.client;
if (!interaction.isCommand()) return;
2022-08-14 22:29:19 +02:00
const globalBlacklist = await db.Blacklists.findOne({ where: { type:'global', uid:interaction.user.id } });
const commandBlacklist = await db.Blacklists.findOne({ where: { type:interaction.commandName, uid:interaction.user.id } });
if (globalBlacklist) {
return interaction.reply({ content: 'You are globally blacklisted.', ephemeral: true });
}
else if (commandBlacklist) {
return interaction.reply({ content: 'You are blacklisted.', ephemeral: true });
}
const command = client.commands.get(interaction.commandName);
2022-06-20 08:34:24 +02:00
console.log(`\x1b[33m${interaction.user.tag} (${interaction.user.id})\x1b[0m launched command \x1b[33m${interaction.commandName}\x1b[0m`);
2022-06-16 13:29:23 +02:00
if (!command) return;
try {
await command.execute(interaction);
}
catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
},
};