fix(arabot): check if user is banned

This commit is contained in:
smyalygames 2022-10-28 03:03:01 +01:00
parent 556038ee80
commit 9d3f687473

View File

@ -20,7 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Message, TextChannel } from 'discord.js';
import IDs from '../../utils/ids';
import { removeBan } from '../../utils/database/ban';
import { removeBan, checkActive } from '../../utils/database/ban';
class UnbanCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -64,27 +64,26 @@ class UnbanCommand extends Command {
return;
}
// Unban the user
try {
await guild.members.unban(user);
} catch {
if (!await checkActive(user.id)) {
await interaction.reply({
content: `${user} is not banned.`,
ephemeral: true,
fetchReply: true,
});
return;
}
// Unban the user
await guild.members.unban(user)
.catch(() => {});
// Add unban to database
await removeBan(user.id, mod.user.id);
await interaction.reply({
content: `${user} has been unbanned.`,
ephemeral: true,
fetchReply: true,
});
// Add unban to database
await removeBan(user.id, mod.user.id);
// Log the ban
let modRestrict = guild.channels.cache.get(IDs.channels.restricted.moderators) as TextChannel | undefined;
@ -127,10 +126,7 @@ class UnbanCommand extends Command {
return;
}
// Unban the user
try {
await guild.members.unban(user);
} catch {
if (!await checkActive(user.id)) {
await message.react('❌');
await message.reply({
content: `${user} is not banned.`,
@ -138,11 +134,15 @@ class UnbanCommand extends Command {
return;
}
await message.react('✅');
// Unban the user
await guild.members.unban(user)
.catch(() => {});
// Add unban to database
await removeBan(user.id, mod.id);
await message.react('✅');
await message.reply({
content: `${user} has been unbanned.`,
});