Added Payment Authorization Middleware
- Default options for commands - Verify user has enough balance to create the transaction - Need to create methods to create transactions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { Events } = require('discord.js');
|
||||
const discordAuth = require('../middleware/discordAuthorization');
|
||||
const { authorizeCommand } = require('../middleware/discordAuthorization');
|
||||
const { authorizeTokenUsage } = require('../middleware/balanceAuthorization');
|
||||
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "interactionCreate");
|
||||
@@ -18,17 +19,19 @@ module.exports = {
|
||||
|
||||
log.DEBUG(`${interaction.member.user} is running '${interaction.commandName}'`);
|
||||
|
||||
await discordAuth.authorizeCommand(interaction, command, () => {
|
||||
try {
|
||||
command.execute(interaction);
|
||||
} catch (error) {
|
||||
log.ERROR(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
interaction.followUp({ 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 });
|
||||
await authorizeCommand(interaction, command, async () => {
|
||||
await authorizeTokenUsage(interaction, command, async () => {
|
||||
try {
|
||||
command.execute(interaction);
|
||||
} catch (error) {
|
||||
log.ERROR(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
interaction.followUp({ 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