From 668a626eaf07caa28785c101d81f28c9d5b73507 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 10 Jun 2023 11:11:19 +1000 Subject: [PATCH] Add new automod rule and remove discriminators --- src/client.ts | 6 +++--- src/commands/bonk.ts | 2 +- src/commands/dev.ts | 4 ++-- src/commands/roleinfo.ts | 2 +- src/commands/suggest.ts | 8 ++++---- src/commands/whois.ts | 4 ++-- src/config.json | 3 ++- src/events/guildBanAdd.ts | 14 ++++++++------ src/events/guildBanRemove.ts | 8 ++++---- src/events/guildMemberAdd.ts | 21 +++++++++++++++------ src/events/guildMemberRemove.ts | 4 +++- src/events/guildMemberUpdate.ts | 4 ++-- src/events/interactionCreate.ts | 4 ++-- src/events/messageCreate.ts | 2 +- src/events/messageDelete.ts | 2 +- src/events/messageReactionAdd.ts | 2 +- src/events/messageReactionRemove.ts | 2 +- src/events/messageUpdate.ts | 2 +- src/index.ts | 2 +- src/models/punishments.ts | 6 +++--- src/typings/interfaces.d.ts | 3 ++- 21 files changed, 60 insertions(+), 45 deletions(-) diff --git a/src/client.ts b/src/client.ts index 7775423..2c5b7eb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -100,7 +100,7 @@ export default class TClient extends Client { socketTimeoutMS: 30000, family: 4 }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(err=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err.reason}`); exec('pm2 stop Daggerbot')}) - this.login(this.tokens.main); + this.login(this.tokens.beta); for await (const file of readdirSync('dist/events')){ const eventFile = await import(`./events/${file}`); this.on(file.replace('.js',''), async(...args)=>eventFile.default.run(this,...args)) @@ -175,8 +175,8 @@ export default class TClient extends Client { const GuildMember = interaction.options.getMember('member') ?? undefined; const User = interaction.options.getUser('member', true); - console.log(this.logTime(), `[PunishmentLog] ${GuildMember?.user?.tag ?? User?.tag ?? 'No user data'} ${time ? ['warn', 'kick'].includes(this.punishments.type) ? 'and no duration set' : `and ${time} (duration)` : ''} was used in /${interaction.commandName} for ${reason}`); - (this.channels.cache.get(this.config.mainServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new this.embed().setColor(this.config.embedColor).setAuthor({name: interaction?.user?.tag, iconURL: interaction?.user?.displayAvatarURL({size:2048})}).setTitle('Punishment Log').setDescription(`${GuildMember?.user?.tag ?? User?.tag ?? 'No user data'} ${time ? ['warn', 'kick'].includes(this.punishments.type) ? 'and no duration set' : `and ${time} (duration)` : ''} was used in \`/${interaction.commandName}\` for \`${reason}\``).setTimestamp()]}); + console.log(this.logTime(), `[PunishmentLog] ${GuildMember?.user?.username ?? User?.username ?? 'No user data'} ${time ? ['warn', 'kick'].includes(this.punishments.type) ? 'and no duration set' : `and ${time} (duration)` : ''} was used in /${interaction.commandName} for ${reason}`); + (this.channels.cache.get(this.config.mainServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new this.embed().setColor(this.config.embedColor).setAuthor({name: interaction?.user?.username, iconURL: interaction?.user?.displayAvatarURL({size:2048})}).setTitle('Punishment Log').setDescription(`${GuildMember?.user?.username ?? User?.username ?? 'No user data'} ${time ? ['warn', 'kick'].includes(this.punishments.type) ? 'and no duration set' : `and ${time} (duration)` : ''} was used in \`/${interaction.commandName}\` for \`${reason}\``).setTimestamp()]}); if (interaction.user.id === User.id) return interaction.reply(`You cannot ${type} yourself.`); if (!GuildMember && type != 'unban') return interaction.reply(`You cannot ${type} someone who is not in the server.`); if (User.bot) return interaction.reply(`You cannot ${type} a bot!`); diff --git a/src/commands/bonk.ts b/src/commands/bonk.ts index d4d3de5..2665e61 100644 --- a/src/commands/bonk.ts +++ b/src/commands/bonk.ts @@ -12,7 +12,7 @@ export default { interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor) .setDescription(`> <@${member.id}> has been bonked!\n${reason?.length == null ? '' : `> Reason: **${reason}**`}`) .setImage('https://media.tenor.com/7tRddlNUNNcAAAAd/hammer-on-head-minions.gif') - .setFooter({text: `Bonk count for ${member.user.tag}: ${await client.bonkCount._content.findById(member.id).then(b=>b.value.toLocaleString('en-US'))}`}) + .setFooter({text: `Bonk count for ${member.displayName}: ${await client.bonkCount._content.findById(member.id).then(b=>b.value.toLocaleString('en-US'))}`}) ]}) }, data: new Discord.SlashCommandBuilder() diff --git a/src/commands/dev.ts b/src/commands/dev.ts index f883d6c..b1458f2 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -37,7 +37,7 @@ export default { {name: 'Input', value: `\`\`\`js\n${code.slice(0, 1010)}\n\`\`\``}, {name: 'Output', value: `\`\`\`\n${err}\`\`\``} ) - interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]})).then(errorEmbedMessage=>{ + interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]})).then(()=>{ const filter = (x:any)=>x.content === 'stack' && x.author.id === interaction.user.id const messagecollector = (interaction.channel as Discord.TextChannel).createMessageCollector({filter, max: 1, time: 60000}); messagecollector.on('collect', collected=>{ @@ -46,7 +46,7 @@ export default { }); } if (error) return; - if (typeof output === 'object') output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output) + if (typeof output === 'object') output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output) else output = '\n' + String(output); [ client.tokens.main,client.tokens.beta,client.tokens.toast,client.tokens.webhook_url, diff --git a/src/commands/roleinfo.ts b/src/commands/roleinfo.ts index 5b97ba1..01cc259 100644 --- a/src/commands/roleinfo.ts +++ b/src/commands/roleinfo.ts @@ -4,7 +4,7 @@ export default { run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ const role = interaction.options.getRole('role') as Discord.Role; const permissions = role.permissions.toArray(); - const Role = role.members.map((e:Discord.GuildMember)=>`**${e.user.tag}**`).join('\n') || ''; + const Role = role.members.map((e:Discord.GuildMember)=>`**${e.user.username}**`).join('\n') || ''; interaction.reply({embeds: [new client.embed().setColor(role.color || '#fefefe').setThumbnail(role?.iconURL()).setTitle(`Role Info: ${role.name}`).addFields( {name: '🔹 ID', value: `\`${role.id}\``, inline: true}, {name: '🔹 Color', value: `\`${role.hexColor}\``, inline: true}, diff --git a/src/commands/suggest.ts b/src/commands/suggest.ts index be442dd..a96bdd4 100644 --- a/src/commands/suggest.ts +++ b/src/commands/suggest.ts @@ -17,7 +17,7 @@ export default { const notifEmbed = new client.embed() .setColor(client.config.embedColor) .setTitle(`Suggestion ID: ${suggestionID}`) - .setAuthor({name: interaction.user.tag, iconURL: interaction.user.avatarURL({size: 256})}) + .setAuthor({name: interaction.user.username, iconURL: interaction.user.avatarURL({size: 256})}) .setFooter({text: `Timestamp: ${timeFormatting}`}) .setDescription([ '> **Suggestion:**', @@ -29,7 +29,7 @@ export default { console.log(e.message); interaction.reply({content: 'Failed to send suggestion, try again later.', ephemeral: true}) }) - await client.suggestion._content.create({_id: suggestionID, idea: suggestionText, user: {_id: interaction.user.id, tag: interaction.user.tag}, state: 'Pending'}); + await client.suggestion._content.create({_id: suggestionID, idea: suggestionText, user: {_id: interaction.user.id, tag: interaction.user.username}, state: 'Pending'}); interaction.reply({content: `Suggestion sent, here is your suggestion ID to take note of it: \`${suggestionID}\``, ephemeral: true}) }, approve: async()=>{ @@ -39,7 +39,7 @@ export default { if ((await client.suggestion._content.findById(suggestionIDReply)).state == 'Rejected') return interaction.reply({content: 'This suggestion\'s state is locked and cannot be modified.', ephemeral: true}); (await client.users.fetch(userid)).send({embeds: [new client.embed() .setColor(client.config.embedColorGreen) - .setAuthor({name: interaction.user.tag, iconURL: interaction.user.avatarURL({size: 256})}) + .setAuthor({name: interaction.user.username, iconURL: interaction.user.avatarURL({size: 256})}) .setTitle('Your suggestion has been approved.') .setDescription(`> **Your suggestion:**\n${theirIdea}\n> **Their message:**\n${replyInDM.length == null ? '*No message from them.*' : replyInDM}`) .setFooter({text: `Timestamp: ${timeFormatting} | Suggestion ID: ${suggestionIDReply}`}) @@ -54,7 +54,7 @@ export default { if ((await client.suggestion._content.findById(suggestionIDReply)).state == 'Approved') return interaction.reply({content: 'This suggestion\'s state is locked and cannot be modified.', ephemeral: true}); (await client.users.fetch(userid)).send({embeds: [new client.embed() .setColor(client.config.embedColorRed) - .setAuthor({name: interaction.user.tag, iconURL: interaction.user.avatarURL({size: 256})}) + .setAuthor({name: interaction.user.username, iconURL: interaction.user.avatarURL({size: 256})}) .setTitle('Your suggestion has been rejected.') .setDescription(`> **Your suggestion:**\n${theirIdea}\n> **Their message:**\n${replyInDM.length == null ? '*No message from them.*' : replyInDM}`) .setFooter({text: `Timestamp: ${timeFormatting} | Suggestion ID: ${suggestionIDReply}`}) diff --git a/src/commands/whois.ts b/src/commands/whois.ts index f5d9687..151225b 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -19,7 +19,7 @@ export default { .setColor(client.config.embedColor) .setURL(`https://discord.com/users/${user.id}`) .setThumbnail(user.avatarURL({size:2048}) || user.defaultAvatarURL) - .setTitle(`${user.bot ? 'Bot': 'User'} Info: ${user.tag}`) + .setTitle(`${user.bot ? 'Bot': 'User'} Info: ${user.username}`) .setDescription(`<@${user.id}>\n\`${user.id}\``) .addFields({name: '🔹 Account Creation Date', value: `\n`}) interaction.reply({embeds: [embed]}) @@ -36,7 +36,7 @@ export default { .setURL(`https://discord.com/users/${member.user.id}`) .setThumbnail(member.user.avatarURL({size:2048}) || member.user.defaultAvatarURL) .setImage(member.user.bannerURL({size:1024}) as string) - .setTitle(`${title} Info: ${member.user.tag}`) + .setTitle(`${title} Info: ${member.user.username}`) .setDescription(`<@${member.user.id}>\n\`${member.user.id}\``) .addFields( {name: '🔹 Account Creation Date', value: `\n`}, diff --git a/src/config.json b/src/config.json index 4a55b13..dbd9b68 100644 --- a/src/config.json +++ b/src/config.json @@ -79,7 +79,8 @@ "botcommands": "468888722210029588", "bankick_log": "1048341961901363352", "fs_server_log": "1104632399771488317", - "punishment_log": "1102751034754998302" + "punishment_log": "1102751034754998302", + "dcmod_chat": "742324777934520350" } } } diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts index 243fb36..2446d25 100644 --- a/src/events/guildBanAdd.ts +++ b/src/events/guildBanAdd.ts @@ -5,13 +5,15 @@ export default { if (member.guild?.id != client.config.mainServer.id) return; const fetchBanlog = await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanAdd}) const banLog = fetchBanlog.entries.first(); - if (!banLog) return console.log(`${member.user.tag} was banned from ${member.guild.name} but no audit log for this user.`) + if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`) const {executor, target, reason } = banLog; - if (target.id === member.user.id) (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [ - new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).setFooter({text:'Rank data has been wiped.'}).addFields( + if (target.id === member.user.id) { + const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.username}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, - {name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`} - )]}); - else console.log(`User was banned from "${member.guild.name}" but no audit log could be fetched.`) + {name: '🔹 Reason', value: `${reason === null ? 'Reason unspecified': reason}`} + ); + if (!await client.userLevels._content.findById(member.user.id)) embed.setFooter({text:'Rank data has been wiped.'}); + (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) + } else console.log(`User was banned from "${member.guild.name}" but no audit log could be fetched.`) } } diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts index 9475423..7c7aced 100644 --- a/src/events/guildBanRemove.ts +++ b/src/events/guildBanRemove.ts @@ -5,13 +5,13 @@ export default { if (member.guild?.id != client.config.mainServer.id) return; const fetchUnbanlog = await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanRemove}) const unbanLog = fetchUnbanlog.entries.first(); - if (!unbanLog) return console.log(`${member.user.tag} was unbanned from ${member.guild.name} but no audit log for this user.`) + if (!unbanLog) return console.log(`User was unbanned from ${member.guild.name} but no audit log for this user.`) const { executor, target, reason } = unbanLog; if (target.id === member.user.id) (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [ - new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( + new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${target.username}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, - {name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified.': reason}`} + {name: '🔹 Reason', value: `${reason === null ? 'Reason unspecified.': reason}`} )]}); - else console.log(`${target.tag} was unbanned from ${member.guild.name} but no audit log could be fetched.`) + else console.log(`User was unbanned from ${member.guild.name} but no audit log could be fetched.`) } } diff --git a/src/events/guildMemberAdd.ts b/src/events/guildMemberAdd.ts index 121d095..5e2fc9f 100644 --- a/src/events/guildMemberAdd.ts +++ b/src/events/guildMemberAdd.ts @@ -1,7 +1,7 @@ import Discord from 'discord.js'; import TClient from '../client.js'; export default { - async run(client:TClient, member:Discord.GuildMember){ + async run(client:TClient, member:Discord.GuildMember){ if (member.partial || member.guild?.id != client.config.mainServer.id) return; const index = member.guild.memberCount; const suffix = (index=>{ @@ -14,16 +14,25 @@ export default { else return 'th'; } })(index); - (client.channels.resolve(client.config.mainServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to Daggerwin, ${member.user.tag}!`).setFooter({text: `${index}${suffix} member`})]}) + let isBot = 'Bot'; + if (!member.user.bot) isBot = 'Member'; if (!client.config.botSwitches.logs) return; + (client.channels.resolve(client.config.mainServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to Daggerwin, ${member.user.username}!`).setFooter({text: `${index}${suffix} member`})]}) const newInvites = await member.guild.invites.fetch(); const usedInvite = newInvites.find((inv:Discord.Invite)=>client.invites.get(inv.code)?.uses < inv.uses); newInvites.forEach((inv:Discord.Invite)=>client.invites.set(inv.code,{uses: inv.uses, creator: inv.inviterId, channel: inv.channel.name})); - + const evadedCase = await client.punishments._content.findOne({'member': member.user.id, type: 'mute', expired: undefined}); (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [ - new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Joined: ${member.user.tag}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).setFooter({text: `Total members: ${index}${suffix}`}).addFields( + new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`${isBot} Joined: ${member.user.username}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).setFooter({text: `Total members: ${index}${suffix}`}).addFields( {name: '🔹 Account Creation Date', value: `\n`}, - {name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.tag}**\nChannel: **#${usedInvite.channel.name}**` : 'No invite data could be fetched.'} - )]}) + {name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.username}**\nChannel: **#${usedInvite.channel.name}**` : 'No invite data could be fetched.'} + )]}); + if (evadedCase){ + (client.channels.resolve(client.config.mainServer.channels.dcmod_chat) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColorYellow).setTitle('Case evasion detected').setDescription([ + `**${member.user.username}** (\`${member.user.id}\`) has been detected for case evasion.`, + 'Timeout has been automatically added. (25 days)' + ].join('\n')).setTimestamp()]}); + await client.punishments.addPunishment('mute', {time: '25d'}, client.user.id, '[AUTOMOD] Case evasion', member.user, member) + } } } diff --git a/src/events/guildMemberRemove.ts b/src/events/guildMemberRemove.ts index 007be45..b5075e2 100644 --- a/src/events/guildMemberRemove.ts +++ b/src/events/guildMemberRemove.ts @@ -5,8 +5,10 @@ export default { if (!client.config.botSwitches.logs) return; if (!member.joinedTimestamp || member.guild?.id != client.config.mainServer.id) return; if (client.guilds.cache.get(client.config.mainServer.id).bans.cache.has(member.id)) return await client.userLevels._content.findByIdAndDelete(member.id); + let isBot = 'Bot'; + if (!member.user.bot) isBot = 'Member'; const levelData = await client.userLevels._content.findById(member.id); - const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string).setTitle(`Member Left: ${member.user.tag}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).addFields( + const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string).setTitle(`${isBot} Left: ${member.user.username}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).addFields( {name: '🔹 Account Creation Date', value: `\n`}, {name: '🔹 Server Join Date', value: `\n`}, {name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: `${member.roles.cache.size > 1 ? member.roles.cache.filter((x)=>x.id !== member.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}`, inline: true} diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts index 3fbf051..7c0eec5 100644 --- a/src/events/guildMemberUpdate.ts +++ b/src/events/guildMemberUpdate.ts @@ -6,7 +6,7 @@ export default { if (!client.config.botSwitches.logs) return; const channel = (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel); if (oldMember.nickname != newMember.nickname){ - const embed = new client.embed().setColor(client.config.embedColor).setTimestamp().setThumbnail(newMember.user.displayAvatarURL({size: 2048})).setTitle(`Nickname updated: ${newMember.user.tag}`).setDescription(`<@${newMember.user.id}>\n\`${newMember.user.id}\``) + const embed = new client.embed().setColor(client.config.embedColor).setTimestamp().setThumbnail(newMember.user.displayAvatarURL({size: 2048})).setTitle(`Nickname updated: ${newMember.user.username}`).setDescription(`<@${newMember.user.id}>\n\`${newMember.user.id}\``) oldMember.nickname == null ? '' : embed.addFields({name: '🔹 Old nickname', value: `\`\`\`${oldMember.nickname}\`\`\``}) newMember.nickname == null ? '' : embed.addFields({name: '🔹 New nickname', value: `\`\`\`${newMember.nickname}\`\`\``}) channel.send({embeds: [embed]}) @@ -15,7 +15,7 @@ export default { const newRoles = newMember.roles.cache.map((x,i)=>i).filter(x=>!oldMember.roles.cache.map((x,i)=>i).some(y=>y==x)); const oldRoles = oldMember.roles.cache.map((x,i)=>i).filter(x=>!newMember.roles.cache.map((x,i)=>i).some(y=>y==x)); if (newRoles.length == 0 && oldRoles.length == 0) return; - const embed = new client.embed().setColor(client.config.embedColor).setThumbnail(newMember.user.displayAvatarURL({size: 2048})).setTitle(`Role updated: ${newMember.user.tag}`).setDescription(`<@${newMember.user.id}>\n\`${newMember.user.id}\``) + const embed = new client.embed().setColor(client.config.embedColor).setThumbnail(newMember.user.displayAvatarURL({size: 2048})).setTitle(`Role updated: ${newMember.user.username}`).setDescription(`<@${newMember.user.id}>\n\`${newMember.user.id}\``) if (newRoles.length != 0) embed.addFields({name: newRoles.length > 1 ? '🔹 Roles added' : '🔹 Role added', value: newRoles.map(x=>`<@&${x}>`).join(' ')}); if (oldRoles.length != 0) embed.addFields({name: oldRoles.length > 1 ? '🔹 Roles removed' : '🔹 Role removed', value: oldRoles.map(x=>`<@&${x}>`).join(' ')}); channel.send({embeds: [embed]}) diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index 2849276..d3405e8 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -5,8 +5,8 @@ export default { if (!interaction.inGuild() || !interaction.inCachedGuild()) return; if (interaction.isChatInputCommand()){ const commandFile = client.commands.get(interaction.commandName); - console.log(client.logTime(), `${interaction.user.tag} used /${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''} in #${interaction.channel.name}`); - if (!client.config.botSwitches.commands && !client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true}); + console.log(client.logTime(), `${interaction.user.username} used /${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''} in #${interaction.channel.name}`); + if (!client.config.botSwitches.commands && !client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: `I am currently operating in development mode.\nPlease notify <@${client.config.whitelist[0]}> if this is a mistake.`, ephemeral: true}); if (commandFile){ try{ commandFile.command.default.run(client, interaction); diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 37e44b5..e5f8dd2 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -26,7 +26,7 @@ export default { }); if (spammedMessage){ delete client.repeatedMessages[message.author.id]; - await client.punishments.addPunishment('mute', {time: muteTime}, (client.user as Discord.User).id, `Automod; ${muteReason}`, message.author, message.member as Discord.GuildMember); + await client.punishments.addPunishment('mute', {time: muteTime}, (client.user as Discord.User).id, `[AUTOMOD] ${muteReason}`, message.author, message.member as Discord.GuildMember); } } else { client.repeatedMessages[message.author.id] = {data: new client.collection(), timeout: setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime)}; diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts index c32b081..2a64627 100644 --- a/src/events/messageDelete.ts +++ b/src/events/messageDelete.ts @@ -7,7 +7,7 @@ export default { const disabledChannels = [ '548032776830582794', '541677709487505408', '949380187668242483'] if (msg.guild?.id != client.config.mainServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return; if (Discord.DiscordAPIError.name === '10008') return console.log(client.logTime(), 'Caught an unexpected error returned by Discord API. (Unknown Message)'); - const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.tag} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``); + const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.username} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``); if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${msg.content.slice(0,1000)}\n\`\`\``}); embed.addFields( { name: 'Channel', value: `<#${msg.channelId}>` }, diff --git a/src/events/messageReactionAdd.ts b/src/events/messageReactionAdd.ts index 82bd7b5..e811894 100644 --- a/src/events/messageReactionAdd.ts +++ b/src/events/messageReactionAdd.ts @@ -6,6 +6,6 @@ export default { if (reaction.message.guildId != client.config.mainServer.id || reaction.message.partial) return; const ReactedFirst = reaction.users.cache.first(); if (ReactedFirst.id != user.id) return; - if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorYellow).setTimestamp().setAuthor({name: `Author: ${ReactedFirst.tag} (${ReactedFirst.id})`, iconURL: `${ReactedFirst.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${ReactedFirst.id}>\nAdded a reaction to the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`).setFooter({text: 'Possibly this member, bot fetches who reacted first.'})], components: [new Discord.ActionRowBuilder().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${reaction.message.url}`).setLabel('Jump to message'))]}); + if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorYellow).setTimestamp().setAuthor({name: `Author: ${ReactedFirst.username} (${ReactedFirst.id})`, iconURL: `${ReactedFirst.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${ReactedFirst.id}>\nAdded a reaction to the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`).setFooter({text: 'Possibly this member, bot fetches who reacted first.'})], components: [new Discord.ActionRowBuilder().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${reaction.message.url}`).setLabel('Jump to message'))]}); } } diff --git a/src/events/messageReactionRemove.ts b/src/events/messageReactionRemove.ts index 8cee6e8..c21ade4 100644 --- a/src/events/messageReactionRemove.ts +++ b/src/events/messageReactionRemove.ts @@ -4,6 +4,6 @@ export default { run(client:TClient, reaction:Discord.MessageReaction, user:Discord.User){ if (!client.config.botSwitches.logs) return; if (reaction.message.guildId != client.config.mainServer.id || reaction.message.partial) return; - if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${user.tag} (${user.id})`, iconURL: `${user.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${user.id}>\nRemoved a reaction from the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`)]}) + if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${user.username} (${user.id})`, iconURL: `${user.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${user.id}>\nRemoved a reaction from the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`)]}) } } diff --git a/src/events/messageUpdate.ts b/src/events/messageUpdate.ts index ada1736..8565079 100644 --- a/src/events/messageUpdate.ts +++ b/src/events/messageUpdate.ts @@ -7,6 +7,6 @@ export default { if (oldMsg.guild?.id != client.config.mainServer.id || oldMsg.author === null || oldMsg?.author.bot || oldMsg.partial || newMsg.partial || !newMsg.member || disabledChannels.includes(newMsg.channelId)) return; if (await client.bannedWords._content.findOne({_id:newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n]/g, ' ').split(' ')}) && (!client.isStaff(newMsg.member))) newMsg.delete(); if (newMsg.content === oldMsg.content) return; - (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.tag} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new Discord.ActionRowBuilder().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]}); + (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.username} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new Discord.ActionRowBuilder().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]}); } } diff --git a/src/index.ts b/src/index.ts index 13c9e76..bbd9227 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,7 @@ client.on('ready', async()=>{ (client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``) })) }; - console.log(`${client.user.tag} has logged into Discord API`); + console.log(`${client.user.username} has logged into Discord API`); console.log(client.config.botSwitches, client.config.whitelistedServers); (client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send({content: `${client.user.username} is active`, embeds:[new client.embed().setColor(client.config.embedColor).setDescription(`\`\`\`json\n${Object.entries(client.config.botSwitches).map(hiTae=>`${hiTae[0]}: ${hiTae[1]}`).join('\n')}\`\`\``)]}); console.timeEnd('Startup') diff --git a/src/models/punishments.ts b/src/models/punishments.ts index 7578808..541b66c 100644 --- a/src/models/punishments.ts +++ b/src/models/punishments.ts @@ -63,7 +63,7 @@ export default class punishments extends Schema { const embed = new this.client.embed() .setColor(this.client.config.embedColor) .setTitle(`Case #${punData._id}: ${type[0].toUpperCase()+type.slice(1)}`) - .setDescription(`${User.tag}\n<@${User.id}>\n(\`${User.id}\`)`) + .setDescription(`${User.username}\n<@${User.id}>\n(\`${User.id}\`)`) .addFields({name: 'Reason', value: reason}) let punResult; let timeInMillis; @@ -140,10 +140,10 @@ export default class punishments extends Schema { 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}\`)`) + .setDescription(`${User.username}\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}` + else return `Successfully un${this.getTense(removePunishmentData.type.replace('un', ''))} ${User.username} (\`${User.id}\`) for ${reason}` } } } diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index b26a747..05e2540 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -175,7 +175,8 @@ export interface Config { botcommands: string, bankick_log: string, fs_server_log: string, - punishment_log: string + punishment_log: string, + dcmod_chat: string } } }