feat(arabot): add logging for giving/removal of roles

This commit is contained in:
smyalygames 2023-03-03 18:37:53 +00:00
parent 22a19da926
commit ddb826c84e
4 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { Guild, User, Message } from 'discord.js'; import type { Guild, User, Message } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { roleAddLog, roleRemoveLog } from '#utils/logging/role';
export class MentorCommand extends Command { export class MentorCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class MentorCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO add database updates
// Get the arguments // Get the arguments
const user = interaction.options.getUser('user', true); const user = interaction.options.getUser('user', true);
const mod = interaction.user; const mod = interaction.user;
@ -128,11 +128,13 @@ export class MentorCommand extends Command {
if (member.roles.cache.has(IDs.roles.staff.mentor)) { if (member.roles.cache.has(IDs.roles.staff.mentor)) {
// Remove the Mentor role from the user // Remove the Mentor role from the user
await member.roles.remove(mentor); await member.roles.remove(mentor);
await roleRemoveLog(user.id, mod.id, mentor, true);
info.message = `Removed the ${mentor.name} role from ${user}`; info.message = `Removed the ${mentor.name} role from ${user}`;
return info; return info;
} }
// Add Mentor role to the user // Add Mentor role to the user
await member.roles.add(mentor); await member.roles.add(mentor);
await roleAddLog(user.id, mod.id, mentor, true);
info.message = `Gave ${user} the ${mentor.name} role!`; info.message = `Gave ${user} the ${mentor.name} role!`;
await user.send(`You have been given the ${mentor.name} role by ${mod}!`) await user.send(`You have been given the ${mentor.name} role by ${mod}!`)

View File

@ -20,6 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { Guild, User, Message } from 'discord.js'; import type { Guild, User, Message } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { roleAddLog, roleRemoveLog } from '#utils/logging/role';
export class ModCommand extends Command { export class ModCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class ModCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO add database updates
// Get the arguments // Get the arguments
const user = interaction.options.getUser('user', true); const user = interaction.options.getUser('user', true);
const mod = interaction.user; const mod = interaction.user;
@ -127,11 +127,13 @@ export class ModCommand extends Command {
if (member.roles.cache.has(IDs.roles.staff.moderator)) { if (member.roles.cache.has(IDs.roles.staff.moderator)) {
// Remove the Mod role from the user // Remove the Mod role from the user
await member.roles.remove(moderator); await member.roles.remove(moderator);
await roleRemoveLog(user.id, mod.id, moderator, true);
info.message = `Removed the ${moderator.name} role from ${user}`; info.message = `Removed the ${moderator.name} role from ${user}`;
return info; return info;
} }
// Add Mod role to the user // Add Mod role to the user
await member.roles.add(moderator); await member.roles.add(moderator);
await roleAddLog(user.id, mod.id, moderator, true);
info.message = `Gave ${user} the ${moderator.name} role!`; info.message = `Gave ${user} the ${moderator.name} role!`;
await user.send(`You have been given the ${moderator.name} role by ${mod}!`) await user.send(`You have been given the ${moderator.name} role by ${mod}!`)

View File

@ -20,6 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { Guild, User, Message } from 'discord.js'; import type { Guild, User, Message } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { roleAddLog, roleRemoveLog } from '#utils/logging/role';
export class RestrictedAccessCommand extends Command { export class RestrictedAccessCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class RestrictedAccessCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO add database updates
// Get the arguments // Get the arguments
const user = interaction.options.getUser('user', true); const user = interaction.options.getUser('user', true);
const mod = interaction.user; const mod = interaction.user;
@ -128,11 +128,13 @@ export class RestrictedAccessCommand extends Command {
if (member.roles.cache.has(IDs.roles.staff.restricted)) { if (member.roles.cache.has(IDs.roles.staff.restricted)) {
// Remove the Restricted Access role from the user // Remove the Restricted Access role from the user
await member.roles.remove(restricted); await member.roles.remove(restricted);
await roleRemoveLog(user.id, mod.id, restricted, true);
info.message = `Removed the ${restricted.name} role from ${user}`; info.message = `Removed the ${restricted.name} role from ${user}`;
return info; return info;
} }
// Add Restricted Access role to the user // Add Restricted Access role to the user
await member.roles.add(restricted); await member.roles.add(restricted);
await roleAddLog(user.id, mod.id, restricted, true);
info.message = `Gave ${user} the ${restricted.name} role!`; info.message = `Gave ${user} the ${restricted.name} role!`;
await user.send(`You have been given the ${restricted.name} role by ${mod}!`) await user.send(`You have been given the ${restricted.name} role by ${mod}!`)

View File

@ -20,6 +20,7 @@
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { Guild, User, Message } from 'discord.js'; import type { Guild, User, Message } from 'discord.js';
import IDs from '#utils/ids'; import IDs from '#utils/ids';
import { roleAddLog, roleRemoveLog } from '#utils/logging/role';
export class StageHostCommand extends Command { export class StageHostCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class StageHostCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO add database updates
// Get the arguments // Get the arguments
const user = interaction.options.getUser('user', true); const user = interaction.options.getUser('user', true);
const mod = interaction.user; const mod = interaction.user;
@ -127,11 +127,13 @@ export class StageHostCommand extends Command {
if (member.roles.cache.has(IDs.roles.stageHost)) { if (member.roles.cache.has(IDs.roles.stageHost)) {
// Remove the Stage Host role from the user // Remove the Stage Host role from the user
await member.roles.remove(stageHost); await member.roles.remove(stageHost);
await roleRemoveLog(user.id, mod.id, stageHost, true);
info.message = `Removed the ${stageHost.name} role from ${user}`; info.message = `Removed the ${stageHost.name} role from ${user}`;
return info; return info;
} }
// Add Stage Host role to the user // Add Stage Host role to the user
await member.roles.add(stageHost); await member.roles.add(stageHost);
await roleAddLog(user.id, mod.id, stageHost, true);
info.message = `Gave ${user} the ${stageHost.name} role!`; info.message = `Gave ${user} the ${stageHost.name} role!`;
await user.send(`You have been given the ${stageHost.name} role by ${mod}!`) await user.send(`You have been given the ${stageHost.name} role by ${mod}!`)