From ddb826c84e4132a5d4aa83c6ea5b2462f4304a7b Mon Sep 17 00:00:00 2001 From: smyalygames Date: Fri, 3 Mar 2023 18:37:53 +0000 Subject: [PATCH] feat(arabot): add logging for giving/removal of roles --- src/commands/roles/staff/mentor.ts | 4 +++- src/commands/roles/staff/mod.ts | 4 +++- src/commands/roles/staff/restrictedAccess.ts | 4 +++- src/commands/roles/staff/stagehost.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/roles/staff/mentor.ts b/src/commands/roles/staff/mentor.ts index 9f711ff..5e39a36 100644 --- a/src/commands/roles/staff/mentor.ts +++ b/src/commands/roles/staff/mentor.ts @@ -20,6 +20,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { Guild, User, Message } from 'discord.js'; import IDs from '#utils/ids'; +import { roleAddLog, roleRemoveLog } from '#utils/logging/role'; export class MentorCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -49,7 +50,6 @@ export class MentorCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { - // TODO add database updates // Get the arguments const user = interaction.options.getUser('user', true); const mod = interaction.user; @@ -128,11 +128,13 @@ export class MentorCommand extends Command { if (member.roles.cache.has(IDs.roles.staff.mentor)) { // Remove the Mentor role from the user await member.roles.remove(mentor); + await roleRemoveLog(user.id, mod.id, mentor, true); info.message = `Removed the ${mentor.name} role from ${user}`; return info; } // Add Mentor role to the user await member.roles.add(mentor); + await roleAddLog(user.id, mod.id, mentor, true); info.message = `Gave ${user} the ${mentor.name} role!`; await user.send(`You have been given the ${mentor.name} role by ${mod}!`) diff --git a/src/commands/roles/staff/mod.ts b/src/commands/roles/staff/mod.ts index 25d05ed..8dd97ae 100644 --- a/src/commands/roles/staff/mod.ts +++ b/src/commands/roles/staff/mod.ts @@ -20,6 +20,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { Guild, User, Message } from 'discord.js'; import IDs from '#utils/ids'; +import { roleAddLog, roleRemoveLog } from '#utils/logging/role'; export class ModCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -48,7 +49,6 @@ export class ModCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { - // TODO add database updates // Get the arguments const user = interaction.options.getUser('user', true); const mod = interaction.user; @@ -127,11 +127,13 @@ export class ModCommand extends Command { if (member.roles.cache.has(IDs.roles.staff.moderator)) { // Remove the Mod role from the user await member.roles.remove(moderator); + await roleRemoveLog(user.id, mod.id, moderator, true); info.message = `Removed the ${moderator.name} role from ${user}`; return info; } // Add Mod role to the user await member.roles.add(moderator); + await roleAddLog(user.id, mod.id, moderator, true); info.message = `Gave ${user} the ${moderator.name} role!`; await user.send(`You have been given the ${moderator.name} role by ${mod}!`) diff --git a/src/commands/roles/staff/restrictedAccess.ts b/src/commands/roles/staff/restrictedAccess.ts index 3d372db..82ef1bc 100644 --- a/src/commands/roles/staff/restrictedAccess.ts +++ b/src/commands/roles/staff/restrictedAccess.ts @@ -20,6 +20,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { Guild, User, Message } from 'discord.js'; import IDs from '#utils/ids'; +import { roleAddLog, roleRemoveLog } from '#utils/logging/role'; export class RestrictedAccessCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -49,7 +50,6 @@ export class RestrictedAccessCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { - // TODO add database updates // Get the arguments const user = interaction.options.getUser('user', true); const mod = interaction.user; @@ -128,11 +128,13 @@ export class RestrictedAccessCommand extends Command { if (member.roles.cache.has(IDs.roles.staff.restricted)) { // Remove the Restricted Access role from the user await member.roles.remove(restricted); + await roleRemoveLog(user.id, mod.id, restricted, true); info.message = `Removed the ${restricted.name} role from ${user}`; return info; } // Add Restricted Access role to the user await member.roles.add(restricted); + await roleAddLog(user.id, mod.id, restricted, true); info.message = `Gave ${user} the ${restricted.name} role!`; await user.send(`You have been given the ${restricted.name} role by ${mod}!`) diff --git a/src/commands/roles/staff/stagehost.ts b/src/commands/roles/staff/stagehost.ts index 3fd8b9b..d2b8ab2 100644 --- a/src/commands/roles/staff/stagehost.ts +++ b/src/commands/roles/staff/stagehost.ts @@ -20,6 +20,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { Guild, User, Message } from 'discord.js'; import IDs from '#utils/ids'; +import { roleAddLog, roleRemoveLog } from '#utils/logging/role'; export class StageHostCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -48,7 +49,6 @@ export class StageHostCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { - // TODO add database updates // Get the arguments const user = interaction.options.getUser('user', true); const mod = interaction.user; @@ -127,11 +127,13 @@ export class StageHostCommand extends Command { if (member.roles.cache.has(IDs.roles.stageHost)) { // Remove the Stage Host role from the user await member.roles.remove(stageHost); + await roleRemoveLog(user.id, mod.id, stageHost, true); info.message = `Removed the ${stageHost.name} role from ${user}`; return info; } // Add Stage Host role to the user await member.roles.add(stageHost); + await roleAddLog(user.id, mod.id, stageHost, true); info.message = `Gave ${user} the ${stageHost.name} role!`; await user.send(`You have been given the ${stageHost.name} role by ${mod}!`)