From 19c13b08f4d4951585b0b7d5e428e69f7253236a Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 30 Apr 2023 09:08:21 +1000 Subject: [PATCH] Add punishment logs to console - For quick user identification before moderation-related command execution. --- src/client.ts | 1 + src/commands/unpunish.ts | 1 + src/events/guildBanAdd.ts | 2 +- src/events/messageCreate.ts | 2 +- src/models/punishments.ts | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 9665c33..ee57b63 100644 --- a/src/client.ts +++ b/src/client.ts @@ -155,6 +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'}`); const time = interaction.options.getString('time') ?? undefined; const reason = interaction.options.getString('reason') ?? 'Reason unspecified'; diff --git a/src/commands/unpunish.ts b/src/commands/unpunish.ts index 7857fbc..ba356a4 100644 --- a/src/commands/unpunish.ts +++ b/src/commands/unpunish.ts @@ -3,6 +3,7 @@ import TClient from '../client.js'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, 'dcmod'); + console.log(client.logTime(), `[UnpunishmentLog] Case ${interaction.options.getInteger('case_id') ?? '--'} was used in /${interaction.commandName} for ${interaction.options.getString('reason') ?? 'Reason unspecified'}`); const punishment = (await client.punishments._content.find({})).find(x=>x._id === interaction.options.getInteger('case_id', true)); if (!punishment) return interaction.reply({content: 'Invalid Case ID', ephemeral: true}); if (punishment.expired) return interaction.reply('This case has been overwritten by another case.'); diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts index fc1e4bd..d0ab9ca 100644 --- a/src/events/guildBanAdd.ts +++ b/src/events/guildBanAdd.ts @@ -12,6 +12,6 @@ export default { {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, {name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`} )]}); - else console.log(`${target.tag} was banned from ${member.guild.name} but no audit log could be fetched.`) + else console.log(`User was banned from "${member.guild.name}" but no audit log could be fetched.`) } } diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index ce235c3..6d9407c 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -108,7 +108,7 @@ export default { if (message.content.toLowerCase().includes('is daggerbot working')) message.reply('https://tenor.com/view/i-still-feel-alive-living-existing-active-singing-gif-14630579'); if (deadChat.some(e=>message.content.toLowerCase().includes(e))) message.reply('https://cdn.discordapp.com/attachments/925589318276382720/1011333656167579849/F57G5ZS.png'); if (msgarr.includes('nawdic') && TheyBrokeIt.some(e=>msgarr.includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Nawdic has done an oopsie*').setImage('https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif').setColor(client.config.embedColor)]}); - if (msgarr.includes('monster') && TheyBrokeIt.some(e=>msgarr.includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Monster has broken something*').setImage('https://media.tenor.com/ZIzIjb_wvEoAAAAC/face-palm.gif').setColor(client.config.embedColor)]}) + if (msgarr.includes('monster') && TheyBrokeIt.some(e=>msgarr.includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Monster has broken something*').setImage('https://media.tenor.com/ZIzIjb_wvEoAAAAC/face-palm.gif').setColor(client.config.embedColor)]}); if (MorningArray.some(e=>message.content.toLowerCase().startsWith(e)) && message.channelId == GeneralChatID && message.type == 0) message.reply(`${MorningPhrases[Math.floor(Math.random()*MorningPhrases.length)]}`); if (AfternoonArray.some(e=>message.content.toLowerCase().startsWith(e)) && message.channelId == GeneralChatID && message.type == 0) message.reply(`${AfternoonPhrases[Math.floor(Math.random()*AfternoonPhrases.length)]}`); if (EveningArray.some(e=>message.content.toLowerCase().startsWith(e)) && message.channelId == GeneralChatID && message.type == 0) message.reply(`${EveningPhrases[Math.floor(Math.random()*EveningPhrases.length)]}`); diff --git a/src/models/punishments.ts b/src/models/punishments.ts index 6c9242f..26980d0 100644 --- a/src/models/punishments.ts +++ b/src/models/punishments.ts @@ -129,7 +129,7 @@ export default class punishments extends Schema { removePunishmentResult = GuildMember.timeout(null, auditLogReason).catch((err:Error)=>err.message); GuildMember.send(`You've been unmuted in ${guild.name}.`).catch((err:Error)=>console.log(err.message)); } else await this._content.findByIdAndUpdate(caseId,{expired:true},{new:true}); - } else removePunishmentData.type = 'removeOtherPunishment'; + } else removePunishmentData.type = 'punishmentOverride'; if (typeof removePunishmentResult == 'string'){//Unsuccessful punishment if (interaction) return interaction.reply(removePunishmentResult);