From d4c043f66fe4cb776776715a07b8aa842af7f1fb Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 30 Apr 2023 09:41:12 +1000 Subject: [PATCH] Improve punishment log a bit better. --- src/client.ts | 2 +- src/config.json | 3 ++- src/models/punishments.ts | 18 ++++++++---------- src/typings/interfaces.d.ts | 3 ++- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/client.ts b/src/client.ts index ee57b63..e7d5bb1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -155,7 +155,7 @@ export default class TClient extends Client { } async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){ if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod"); - console.log(client.logTime(), `[PunishmentLog] ${interaction.options.data.map(u=>u.user?.tag)} was used in /${interaction.commandName} for ${interaction.options.getString('reason') ?? 'Reason unspecified'}`); + console.log(client.logTime(), `[PunishmentLog] ${interaction.options.getMember('member')?.user.tag ? 'No user data' : interaction.options.getUser('member')?.tag} and ${interaction.options.getString('time') ?? 'No duration set'} was used in /${interaction.commandName} for ${interaction.options.getString('reason') ?? 'Reason unspecified'}`); const time = interaction.options.getString('time') ?? undefined; const reason = interaction.options.getString('reason') ?? 'Reason unspecified'; diff --git a/src/config.json b/src/config.json index 6c50fa7..d7e3a09 100644 --- a/src/config.json +++ b/src/config.json @@ -65,7 +65,8 @@ "bot_status": "1009753780188884992", "logs": "548032776830582794", "welcome": "621134751897616406", - "botcommands": "468888722210029588" + "botcommands": "468888722210029588", + "bankick_log": "1048341961901363352" } } } diff --git a/src/models/punishments.ts b/src/models/punishments.ts index 26980d0..166df9f 100644 --- a/src/models/punishments.ts +++ b/src/models/punishments.ts @@ -28,9 +28,8 @@ export default class punishments extends Schema { createId = async()=>Math.max(...(await this._content.find({})).map(x=>x.id), 0) + 1; async makeModlogEntry(punishment:Punishment){ // Format data into an embed - const channel = ['kick', 'ban'].includes(punishment.type) ? '1048341961901363352' : this.client.config.mainServer.channels.logs; - const embed = new this.client.embed() - .setTitle(`${punishment.type[0].toUpperCase() + punishment.type.slice(1)} | Case #${punishment._id}`) + const channel = ['kick', 'ban'].includes(punishment.type) ? this.client.config.mainServer.channels.bankick_log : this.client.config.mainServer.channels.logs; + const embed = new this.client.embed().setTitle(`${punishment.type[0].toUpperCase() + punishment.type.slice(1)} | Case #${punishment._id}`) .addFields( {name: '🔹 User', value: `<@${punishment.member}>\n\`${punishment.member}\``, inline: true}, {name: '🔹 Moderator', value: `<@${punishment.moderator}>\n\`${punishment.moderator}\``, inline: true}, @@ -139,13 +138,12 @@ export default class punishments extends Schema { await this._content.create(removePunishmentData); await this.makeModlogEntry(removePunishmentData); - if (interaction) { - return interaction.reply({embeds:[new this.client.embed().setColor(this.client.config.embedColor) - .setTitle(`Case #${removePunishmentData._id}: ${removePunishmentData.type[0].toUpperCase()+removePunishmentData.type.slice(1)}`) - .setDescription(`${User.tag}\n<@${User.id}>\n(\`${User.id}\`)`) - .addFields({name: 'Reason', value: reason},{name: 'Overwrites', value: `Case #${punishment.id}`}) - ]}) - } else return `Successfully un${this.getTense(removePunishmentData.type.replace('un', ''))} ${User.tag} (\`${User.id}\`) for ${reason}` + if (interaction) return interaction.reply({embeds:[new this.client.embed().setColor(this.client.config.embedColor) + .setTitle(`Case #${removePunishmentData._id}: ${removePunishmentData.type[0].toUpperCase()+removePunishmentData.type.slice(1)}`) + .setDescription(`${User.tag}\n<@${User.id}>\n(\`${User.id}\`)`) + .addFields({name: 'Reason', value: reason},{name: 'Overwrites', value: `Case #${punishment.id}`}) + ]}); + else return `Successfully un${this.getTense(removePunishmentData.type.replace('un', ''))} ${User.tag} (\`${User.id}\`) for ${reason}` } } } diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index 93db5b5..0ded2e4 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -184,5 +184,6 @@ interface mainServerChannels { bot_status: string, logs: string, welcome: string, - botcommands: string + botcommands: string, + bankick_log: string } \ No newline at end of file