Updated Logging & Added Auth Middleware
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
const { Events } = require('discord.js');
|
const { Events } = require('discord.js');
|
||||||
|
const discordAuth = require('../middleware/discordAuthorization');
|
||||||
|
|
||||||
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
|
const log = new DebugBuilder("server", "interactionCreate");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
@@ -8,21 +12,23 @@ module.exports = {
|
|||||||
const command = interaction.client.commands.get(interaction.commandName);
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
log.ERROR(`No command matching ${interaction.commandName} was found.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.DEBUG(`${interaction.member.user} is running '${interaction.commandName}'`);
|
log.DEBUG(`${interaction.member.user} is running '${interaction.commandName}'`);
|
||||||
|
|
||||||
try {
|
await discordAuth.authorizeCommand(interaction, command, () => {
|
||||||
await command.execute(interaction);
|
try {
|
||||||
} catch (error) {
|
command.execute(interaction);
|
||||||
console.error(error);
|
} catch (error) {
|
||||||
if (interaction.replied || interaction.deferred) {
|
log.ERROR(error);
|
||||||
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
if (interaction.replied || interaction.deferred) {
|
||||||
} else {
|
interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||||
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
} else {
|
||||||
|
interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user