chore: improve safety of commands

This commit is contained in:
Ahmad 2025-04-17 01:05:10 -04:00
parent 83bbf7b098
commit 7c2a99daf5
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
28 changed files with 329 additions and 235 deletions

View file

@ -71,12 +71,16 @@ const command: SubcommandCommand = {
),
),
execute: async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (!interaction.isChatInputCommand() || !interaction.guild) return;
const commandUser = interaction.guild?.members.cache.get(
const commandUser = interaction.guild.members.cache.get(
interaction.user.id,
);
await interaction.deferReply({
flags: ['Ephemeral'],
});
const config = loadConfig();
const managerRoleId = config.roles.staffRoles.find(
(role) => role.name === 'Manager',
@ -87,18 +91,12 @@ const command: SubcommandCommand = {
!managerRoleId ||
commandUser.roles.highest.comparePositionTo(managerRoleId) < 0
) {
await interaction.reply({
await interaction.editReply({
content: 'You do not have permission to use this command',
flags: ['Ephemeral'],
});
return;
}
await interaction.deferReply({
flags: ['Ephemeral'],
});
await interaction.editReply('Processing...');
const subcommand = interaction.options.getSubcommand();
const user = interaction.options.getUser('user', true);
const amount = interaction.options.getInteger('amount', false);