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

This commit is contained in:
smyalygames 2023-03-03 18:37:06 +00:00
parent 232cbc4b67
commit 22a19da926
12 changed files with 36 additions and 11 deletions

View File

@ -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 BookClubCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class BookClubCommand 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 BookClubCommand extends Command {
if (member.roles.cache.has(IDs.roles.bookClub)) {
// Remove the Book Club role from the user
await member.roles.remove(bookClub);
await roleRemoveLog(user.id, mod.id, bookClub);
info.message = `Removed the ${bookClub.name} role from ${user}`;
return info;
}
// Add Book Club role to the user
await member.roles.add(bookClub);
await roleAddLog(user.id, mod.id, bookClub);
info.message = `Gave ${user} the ${bookClub.name} role!`;
await user.send(`You have been given the ${bookClub.name} role by ${mod}!`)

View File

@ -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 DebateHostCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -127,11 +128,13 @@ export class DebateHostCommand extends Command {
if (member.roles.cache.has(IDs.roles.debateHost)) {
// Remove the Debate Host role from the user
await member.roles.remove(debateHost);
await roleRemoveLog(user.id, mod.id, debateHost);
info.message = `Removed the ${debateHost.name} role from ${user}`;
return info;
}
// Add Debate Host role to the user
await member.roles.add(debateHost);
await roleAddLog(user.id, mod.id, debateHost);
info.message = `Gave ${user} the ${debateHost.name} role!`;
await user.send(`You have been given the ${debateHost.name} role by ${mod}!`)

View File

@ -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 GameNightHostCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class GameNightHostCommand 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 GameNightHostCommand extends Command {
if (member.roles.cache.has(IDs.roles.gameNightHost)) {
// Remove the Game Night Host role from the user
await member.roles.remove(gameNightHost);
await roleRemoveLog(user.id, mod.id, gameNightHost);
info.message = `Removed the ${gameNightHost.name} role from ${user}`;
return info;
}
// Add Game Night Host role to the user
await member.roles.add(gameNightHost);
await roleAddLog(user.id, mod.id, gameNightHost);
info.message = `Gave ${user} the ${gameNightHost.name} role!`;
await user.send(`You have been given the ${gameNightHost.name} role by ${mod}!`)

View File

@ -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 GuestCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class GuestCommand 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 GuestCommand extends Command {
if (member.roles.cache.has(IDs.roles.guest)) {
// Remove the Guest role from the user
await member.roles.remove(guest);
await roleRemoveLog(user.id, mod.id, guest);
info.message = `Removed the ${guest.name} role from ${user}`;
return info;
}
// Add Guest role to the user
await member.roles.add(guest);
await roleAddLog(user.id, mod.id, guest);
info.message = `Gave ${user} the ${guest.name} role!`;
await user.send(`You have been given the ${guest.name} role by ${mod}!`)

View File

@ -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 TrialVerifierCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class TrialVerifierCommand 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 TrialVerifierCommand extends Command {
if (member.roles.cache.has(IDs.roles.staff.trialVerifier)) {
// Remove the Trial Verifier role from the user
await member.roles.remove(trialVerifier);
await roleRemoveLog(user.id, mod.id, trialVerifier, true);
info.message = `Removed the ${trialVerifier.name} role from ${user}`;
return info;
}
// Add Trial Verifier role to the user
await member.roles.add(trialVerifier);
await roleAddLog(user.id, mod.id, trialVerifier, true);
info.message = `Gave ${user} the ${trialVerifier.name} role!`;
await user.send(`You have been given the ${trialVerifier.name} role by ${mod}!`)

View File

@ -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 VerifierCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -48,7 +49,6 @@ export class VerifierCommand 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 VerifierCommand extends Command {
if (member.roles.cache.has(IDs.roles.staff.verifier)) {
// Remove the Verifier role from the user
await member.roles.remove(verifier);
await roleRemoveLog(user.id, mod.id, verifier, true);
info.message = `Removed the ${verifier.name} role from ${user}`;
return info;
}
// Add Verifier role to the user
await member.roles.add(verifier);
await roleAddLog(user.id, mod.id, verifier, true);
info.message = `Gave ${user} the ${verifier.name} role!`;
await user.send(`You have been given the ${verifier.name} role by ${mod}!`)

View File

@ -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 ActivistCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class ActivistCommand 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;
@ -142,12 +142,14 @@ export class ActivistCommand extends Command {
// Remove the Activist role from the user
await member.roles.remove(activist);
await roleRemoveLog(user.id, mod.id, activist);
info.message = `Removed the ${activist.name} role from ${user}`;
return info;
}
// Add Activist role to the user
await member.roles.add(activist);
await roleAddLog(user.id, mod.id, activist);
info.message = `Gave ${user} the ${activist.name} role!`;
await user.send(

View File

@ -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 ConvincedCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class ConvincedCommand 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;
@ -133,11 +133,13 @@ export class ConvincedCommand extends Command {
if (member.roles.cache.has(IDs.roles.nonvegan.convinced)) {
// Remove the Convinced role from the user
await member.roles.remove(convinced);
await roleRemoveLog(user.id, mod.id, convinced);
info.message = `Removed the ${convinced.name} role from ${user}`;
return info;
}
// Add Convinced role to the user
await member.roles.add(convinced);
await roleAddLog(user.id, mod.id, convinced);
info.message = `Gave ${user} the ${convinced.name} role!`;
await user.send(`You have been given the ${convinced.name} role by ${mod}!`

View File

@ -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 PlusCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class PlusCommand 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 PlusCommand extends Command {
if (member.roles.cache.has(IDs.roles.vegan.plus)) {
// Remove the Plus role from the user
await member.roles.remove(plus);
await roleRemoveLog(user.id, mod.id, plus);
info.message = `Removed the ${plus.name} role from ${user}`;
return info;
}
// Add Plus role to the user
await member.roles.add(plus);
await roleAddLog(user.id, mod.id, plus);
info.message = `Gave ${user} the ${plus.name} role!`;
await user.send(`You have been given the ${plus.name} role by ${mod}!`)

View File

@ -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 TrustedCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class TrustedCommand 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 TrustedCommand extends Command {
if (member.roles.cache.has(IDs.roles.trusted)) {
// Remove the Trusted role from the user
await member.roles.remove(trusted);
await roleRemoveLog(user.id, mod.id, trusted);
info.message = `Removed the ${trusted.name} role from ${user}`;
return info;
}
// Add Trusted role to the user
await member.roles.add(trusted);
await roleAddLog(user.id, mod.id, trusted);
info.message = `Gave ${user} the ${trusted.name} role!`;
await user.send(`You have been given the ${trusted.name} role by ${mod}!`

View File

@ -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 VeganCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class VeganCommand 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;
@ -146,6 +146,7 @@ export class VeganCommand extends Command {
vegan,
IDs.roles.vegan.activist,
]);
await roleRemoveLog(user.id, mod.id, vegan);
info.message = `Removed the ${vegan.name} role from ${user}`;
return info;
}
@ -157,6 +158,7 @@ export class VeganCommand extends Command {
IDs.roles.nonvegan.convinced,
IDs.roles.nonvegan.vegCurious,
]);
await roleAddLog(user.id, mod.id, vegan);
info.message = `Gave ${user} the ${vegan.name} role!`;
await user.send(`You have been given the ${vegan.name} role by ${mod}!`)

View File

@ -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 VegCuriousCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
@ -49,7 +50,6 @@ export class VegCuriousCommand 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;
@ -139,12 +139,14 @@ export class VegCuriousCommand extends Command {
// Remove the Veg Curious role from the user
await member.roles.remove(vegCurious);
await roleRemoveLog(user.id, mod.id, vegCurious);
info.message = `Removed the ${vegCurious.name} role from ${user}`;
return info;
}
// Add Veg Curious role to the user
await member.roles.add(vegCurious);
await roleAddLog(user.id, mod.id, vegCurious);
info.message = `Gave ${user} the ${vegCurious.name} role!`;
await user.send(`You have been given the ${vegCurious.name} role by ${mod} `