From 857319e1367fd1d93ca8e9387c6980c0b48a808b Mon Sep 17 00:00:00 2001 From: smyalygames Date: Fri, 17 Mar 2023 00:54:19 +0000 Subject: [PATCH] feat(arabot): add log to log channel for payments --- src/commands/economy/pay.ts | 21 ++++++++++++++++++++- src/utils/devIDs.ts | 1 + src/utils/ids.ts | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/commands/economy/pay.ts b/src/commands/economy/pay.ts index 595ffa4..cd6a2dd 100644 --- a/src/commands/economy/pay.ts +++ b/src/commands/economy/pay.ts @@ -21,7 +21,8 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { User, Guild, Message } from 'discord.js'; import { updateUser } from '#utils/database/dbExistingUser'; import { getBalance, transfer } from '#utils/database/economy'; -import { EmbedBuilder } from 'discord.js'; +import { EmbedBuilder, TextChannel } from 'discord.js'; +import IDs from '#utils/ids'; export class BalanceCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -176,6 +177,24 @@ export class BalanceCommand extends Command { info.success = true; info.embeds.push(embed); + + // Log the payment in the server + let logChannel = guild.channels.cache + .get(IDs.channels.logs.economy) as TextChannel | undefined; + + if (logChannel === undefined) { + logChannel = await guild.channels + .fetch(IDs.channels.logs.economy) as TextChannel | undefined; + if (logChannel === undefined) { + this.container.logger.error('Pay Error: Could not fetch log channel'); + return info; + } + } + + embed + .setTimestamp() + .setFooter({ text: `ID: ${user.id}` }); + await logChannel.send({ embeds: [embed] }); return info; } } diff --git a/src/utils/devIDs.ts b/src/utils/devIDs.ts index dc8cccf..f378f4f 100644 --- a/src/utils/devIDs.ts +++ b/src/utils/devIDs.ts @@ -118,6 +118,7 @@ const devIDs = { }, logs: { restricted: '999431681217937513', + economy: '999431681599623198', }, }, categories: { diff --git a/src/utils/ids.ts b/src/utils/ids.ts index f3c8c9d..01299ef 100644 --- a/src/utils/ids.ts +++ b/src/utils/ids.ts @@ -121,6 +121,7 @@ let IDs = { }, logs: { restricted: '920993034462715925', + economy: '932050015034159174', }, }, categories: {