mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 07:14:14 +02:00
fix(arabot): check if user is banned
This commit is contained in:
parent
556038ee80
commit
9d3f687473
@ -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.`,
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user