-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Embeds, Pardons + Purges #11
base: master
Are you sure you want to change the base?
Better Embeds, Pardons + Purges #11
Conversation
Overhaulled all embeds within the bot, added mod logs, and first implantation of buttons.
Added purge.js command, which can either delete 2-99 messages or delete 100 messages from a user.
Added pardon command, removed useless ??? else comment, replaced generic icon in purge, and other misc. fixes.
Logs unbans and now follows the correct naming convention.
Ok, all issues I can think of has been fix, this should be able to be merged without causing too much issues. |
Adds joke regexes, which will reply (within the select channel) with a certain prompt.
Adds the missing bracket of the switch function
Fixes problem where it'd ping the bot itself instead of the user, and removed useless switch function.
Some minor bugfixes, just to wrap the joke regexes perfectly.
Makes sure to check hierarchy before banning/kicking/warning, also fixes crashing in the case no reasoning is given when manually banning/kicking.
Replaces settings-which to discord options, similarly to Bandwidth.
Fixed a lil bug where it would say "Undefined cannot be warned". Also added Eyad's warnings suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's quite a few spacing/indentation issues in various files, and several pieces of information that were there to give context to the user was removed without reason
src/commands/ban.js
Outdated
bansListEmbed.setColor(0xFFA500); | ||
bansListEmbed.setTitle('User Bans'); | ||
bansListEmbed.setColor(0xa30000); | ||
const image = new Discord.MessageAttachment('./src/images/mod/mod-ban.png'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very awkward place to define this image variable, it should either be moved to above the embed creation or further down closer to where it's used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's positioned there due to the fact of where it's used. However, I have moved it to be closer to the related functions.
sendMemberEmbeds.push(banEmbed); | ||
|
||
if (count > 0) { | ||
const pastBansEmbed = new Discord.MessageEmbed(); | ||
pastBansEmbed.setTitle('Past Bans'); | ||
pastBansEmbed.setDescription('For clarifty purposes here is a list of your past bans'); | ||
pastBansEmbed.setColor(0xEF7F31); | ||
pastBansEmbed.setTimestamp(Date.now()); | ||
pastBansEmbed.setFooter({ | ||
text: 'Pretendo Network', | ||
iconURL: guild.iconURL() | ||
}); | ||
|
||
for (let i = 0; i < rows.length; i++) { | ||
const ban = rows[i]; | ||
const bannedBy = await interaction.client.users.fetch(ban.admin_user_id); | ||
|
||
pastBansEmbed.addFields( | ||
{ | ||
name: `${util.ordinal(i + 1)} Ban`, | ||
value: ban.reason | ||
}, | ||
{ | ||
name: 'Punished By', | ||
value: bannedBy.tag, | ||
inline: true | ||
}, | ||
{ | ||
name: 'Date', | ||
value: ban.timestamp.toLocaleDateString(), | ||
inline: true | ||
} | ||
); | ||
} | ||
|
||
sendMemberEmbeds.push(pastBansEmbed); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to possible errors with the new pardon system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What possible errors? Can you be more specific?
src/events/guildMemberAdd.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this neccessary? There's already a channel which logs this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but it does clean it up a bit. If you do want me to simply use the default one, then I'll remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/util.js
Outdated
if (components === null) { | ||
await logChannel.send({ embeds: [embed], files: [file] }); | ||
} else { | ||
await logChannel.send({ embeds: [embed], files: [file], components: [components] }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check neccessary? Won't Discord.JS just not do anything with components
if it's falsey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, might need some testing.
src/events/messageDelete.js
Outdated
|
||
const { executor } = latestLog; | ||
|
||
if (executor.id = guild.me.id) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad equals check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly fixed?
Outside of spacing, most issues should be resolved. although in my end it's hard to deal with indents/spacing since i cannot discern which is which, and it seems like they do mix around indents with spacing, making fixing said issues harder. If you could do a quick re-review, that'd be great. |
There are tools for this. Depending on your editor there's usually a setting to show indentation. In VS Code this is the This project also uses ESLint for linting, and has a rule for indentation. Depending on your editor, there is usually some setting or plugin/extension which shows ESLint errors in the editor. You can also run
Also for your browser there's an extension called Refined GitHub which adds many missing QoL features to the site, one of which is showing spaces vs tabs
I'll do another review once the spacing issues are fixed and the previous comments are resolved, just to save everyone some time |
Fixed spacing and fixed some other stuff that was clearly broken via testing. Feel free to review now. |
Actually, I have noticed that this one doesn’t have an easy way to see amount of kicks, so don’t merge the PR just yet until I add that, but a review of anything I need to fix/revise as of now would be good. |
Alright, did all of the last minute tweaks, feel free to do a re-review. |
Chubby can now delete polls
No longer removes attachments
README.md
Outdated
Chubby can: | ||
- Detect and remove NSFW content | ||
- Warn, kick, and ban multiple users at once | ||
- Pardon warns and kicks from multiple users | ||
- Purge messages from a channel or from a specified user | ||
- Log user and moderation events | ||
- Remove Discord polls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed the names of the commands for these features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, re-added them in the next commit.
src/commands/ban.js
Outdated
bansListEmbed.setColor(0xa30000); | ||
bansListEmbed.setThumbnail('attachment://mod-ban.png'); | ||
|
||
const image = new Discord.MessageAttachment('./src/images/mod/mod-ban.png'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly a nitpick, but please try to define variables like these close to where they will be used. Right now the way code like this reads, it's not clear right away where image
is used when going top down. If going bottom up then it's not clear where image
comes from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I can't get as close as I wish I could, however I will rename them to be more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you're correct. I missed where this was used inside the loop. This placement is fine
|
||
for (const userId of userIds) { | ||
const member = await interaction.guild.members.fetch(userId); | ||
const user = member.user; | ||
|
||
// Checks if they're above/equal to the executor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes for all comments. We use the syntax from Better Comments now. I've been migrating our older code to use it, but newer code should use it by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I use VS2022, so I'm not certain if I'll be able to see them, but nonetheless, I'll try implementing that after I resolve everything else.
src/commands/kick.js
Outdated
name: 'From bot /kick command', | ||
name: 'From Bot', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already clear this is from the bot, that's the only way these messages get sent. The point of this naming convention was to note if the kick was specifically from calling the /kick
command, or if it was from the result of multiple warnings. Both of those actions come from the bot, this is used to know WHICH action it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, gotcha. Sorry, I have reverted that change now.
src/commands/kick.js
Outdated
await util.sendEventLogMessage(guild, null, eventLogEmbed); | ||
|
||
if (count > 0) { | ||
const pastKicksEmbed = new Discord.MessageEmbed(); | ||
pastKicksEmbed.setTitle('Past Kicks'); | ||
pastKicksEmbed.setDescription('For clarifty purposes here is a list of your past kicks'); | ||
pastKicksEmbed.setColor(0xEF7F31); | ||
pastKicksEmbed.setTimestamp(Date.now()); | ||
pastKicksEmbed.setFooter({ | ||
text: 'Pretendo Network', | ||
iconURL: guild.iconURL() | ||
}); | ||
|
||
for (let i = 0; i < rows.length; i++) { | ||
const kick = rows[i]; | ||
const kickedBy = await interaction.client.users.fetch(kick.admin_user_id); | ||
|
||
pastKicksEmbed.addFields( | ||
{ | ||
name: `${util.ordinal(i + 1)} Kick`, | ||
value: kick.reason | ||
}, | ||
{ | ||
name: 'Punished By', | ||
value: kickedBy.tag, | ||
inline: true | ||
}, | ||
{ | ||
name: 'Date', | ||
value: kick.timestamp.toLocaleDateString(), | ||
inline: true | ||
} | ||
); | ||
} | ||
|
||
sendMemberEmbeds.push(pastKicksEmbed); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What breaks? I'm confused what specific issues this caused. All this seems to do is removed additional context?
warningListEmbed.addFields( | ||
{ | ||
name: `${user.username}'s warns`, | ||
value: count.toString() | ||
}, | ||
{ | ||
name: 'Warnings Left Until Kick', | ||
value: Math.max(0, 3 - count).toString() | ||
}, | ||
{ | ||
name: 'Warnings Left Until Ban', | ||
value: Math.max(0, 4 - count).toString() | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Information about the warnings?
src/events/guildMemberAdd.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/events/messageCreate.js
Outdated
message.delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (message.content == '' && message.attachments.size == 0) | |
message.delete(); | |
if (!message.content.trim() && message.attachments.size == 0) { | |
await message.delete(); | |
return | |
} | |
src/events/messageDelete.js
Outdated
eventLogEmbed.setTitle('_Poll Delete_'); | ||
eventLogEmbed.setDescription(`${user.username}'s poll in ${message.channel.name} has been deleted`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed to only mention polls...? This should trigger on any message being deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, Discord.js doesn’t support polls yet, which is why most of the poll deletion is hacky. Ideally, you would have some sort of “event/PollRemove.js” event which fires off when client detects a poll deletion.
Technically, you could call some function after poll deletion in “event/MessageCreate.js”, but again not ideal.
…hubby-v2 into chubby-overhaul
Additions
/setting-which
to just Discord options