feat(arabot): add database logging for bans

This commit is contained in:
smyalygames 2022-10-28 02:25:18 +01:00
parent a40925e9e9
commit 51082db025
2 changed files with 14 additions and 2 deletions

View File

@ -20,6 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { GuildMember, Message, TextChannel } from 'discord.js';
import IDs from '../../utils/ids';
import { addBan } from '../../utils/database/ban';
class BanCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -51,7 +52,6 @@ class BanCommand extends Command {
// Command run
public async chatInputRun(interaction: Command.ChatInputInteraction) {
// TODO add database updates
// Get the arguments
const user = interaction.options.getUser('user');
const reason = interaction.options.getString('reason');
@ -106,6 +106,9 @@ class BanCommand extends Command {
fetchReply: true,
});
// Add ban to database
await addBan(user.id, mod.user.id, reason);
// Log the ban
let logChannel = guild.channels.cache.get(IDs.channels.logs.restricted) as TextChannel | undefined;
@ -181,6 +184,9 @@ class BanCommand extends Command {
await message.react('✅');
// Add ban to database
await addBan(user.id, mod.id, reason);
// Log the ban
let logChannel = guild.channels.cache.get(IDs.channels.logs.restricted) as TextChannel | undefined;

View File

@ -20,6 +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';
class UnbanCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ class UnbanCommand extends Command {
// Command run
public async chatInputRun(interaction: Command.ChatInputInteraction) {
// TODO add database updates
// Get the arguments
const user = interaction.options.getUser('user');
const mod = interaction.member;
@ -73,6 +73,9 @@ class UnbanCommand extends Command {
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;
@ -120,6 +123,9 @@ class UnbanCommand extends Command {
await message.react('✅');
// Add unban to database
await removeBan(user.id, mod.id);
await message.reply({
content: `${user} has been unbanned.`,
});