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:
Logan Cusano
2023-02-26 00:51:56 -05:00
parent 8ed30ad171
commit f3bae7e223
5 changed files with 206 additions and 34 deletions

View File

@@ -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 });
}
}
}
})
});
},
};