feat(arabot): add check if user is already banned

This commit is contained in:
smyalygames 2022-10-28 03:07:31 +01:00
parent 534b45f5db
commit 1c5ec53b3b

View File

@ -20,7 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { User, Message, TextChannel } from 'discord.js'; import type { User, Message, TextChannel } from 'discord.js';
import IDs from '../../utils/ids'; import IDs from '../../utils/ids';
import { addBan } from '../../utils/database/ban'; import { addBan, checkActive } from '../../utils/database/ban';
class BanCommand extends Command { class BanCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -81,6 +81,11 @@ class BanCommand extends Command {
return; return;
} }
if (await checkActive(user.id)) {
await interaction.reply(`${user} is already banned!`);
return;
}
// Checks if the user is not restricted // Checks if the user is not restricted
if (guildMember.roles.cache.has(IDs.roles.vegan.vegan) if (guildMember.roles.cache.has(IDs.roles.vegan.vegan)
|| guildMember.roles.cache.has(IDs.roles.nonvegan.nonvegan)) { || guildMember.roles.cache.has(IDs.roles.nonvegan.nonvegan)) {
@ -157,6 +162,12 @@ class BanCommand extends Command {
return; return;
} }
if (await checkActive(user.id)) {
await message.react('❌');
await message.reply(`${user} is already banned!`);
return;
}
if (message.channel.id !== IDs.channels.restricted.moderators) { if (message.channel.id !== IDs.channels.restricted.moderators) {
await message.react('❌'); await message.react('❌');
await message.reply(`You can only run this command in <#${IDs.channels.restricted.moderators}> ` await message.reply(`You can only run this command in <#${IDs.channels.restricted.moderators}> `