-
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?
Changes from 20 commits
3b21377
c429f4a
43c75a8
7f0bbe6
4a35b85
6133180
24e2ccd
29db884
3f14f4c
637cc2c
afc8adb
51419ab
791a73f
5ec875c
f22dfec
e2b6b39
05e4770
11f336c
4606c5c
cfbdc86
560d2e2
a55e42d
c94428d
00fce5c
6555d29
147a211
489cdaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# Chubby | ||
Discord moderation bot for Pretendo | ||
![Chubby Banner](./src/images/misc/chubby-banner.png) | ||
--- | ||
Chubby, the official Pretendo Network Discord moderation bot. | ||
|
||
Features: | ||
|
||
- `/warn` command for warning users. Supports multiple users per warning. 3 warnings results in a kick. 4 warnings results in a ban | ||
- `/kick` command for kicking users. Supports multiple users per kick. 3 kicks results in a ban | ||
- `/ban` command for banning users. Supports multiple users per warning | ||
- NSFW content detection | ||
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 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,33 @@ async function banHandler(interaction) { | |
const userIds = [...new Set(Array.from(users.matchAll(Discord.MessageMentions.USERS_PATTERN), match => match[1]))]; | ||
|
||
const bansListEmbed = new Discord.MessageEmbed(); | ||
bansListEmbed.setTitle('User Bans :thumbsdown:'); | ||
bansListEmbed.setColor(0xFFA500); | ||
bansListEmbed.setTitle('User Bans'); | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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. |
||
if (member.roles.highest.position >= executingMember.roles.highest.position) { | ||
await interaction.editReply(`You cannot ban ${user.username} as they have a higher role compared to you.`); | ||
return; | ||
} | ||
|
||
// Creates mod logs | ||
const eventLogEmbed = new Discord.MessageEmbed(); | ||
|
||
eventLogEmbed.setColor(0xF24E43); | ||
eventLogEmbed.setDescription('――――――――――――――――――――――――――――――――――'); | ||
eventLogEmbed.setAuthor({ | ||
name: user.tag, | ||
iconURL: user.avatarURL() | ||
}); | ||
eventLogEmbed.setColor(0xa30000); | ||
eventLogEmbed.setDescription(`${user.username} has been banned by ${executor.username}`); | ||
eventLogEmbed.setTimestamp(Date.now()); | ||
eventLogEmbed.setTitle('Event Type: _Member Banned_'); | ||
eventLogEmbed.setTitle('_Member Banned_'); | ||
eventLogEmbed.setFields( | ||
{ | ||
name: 'User', | ||
|
@@ -44,96 +58,59 @@ async function banHandler(interaction) { | |
value: user.id | ||
}, | ||
{ | ||
name: 'Executor', | ||
name: 'Moderator', | ||
value: `<@${executor.id}>` | ||
}, | ||
{ | ||
name: 'Executor User ID', | ||
name: 'Moderator User ID', | ||
value: executor.id | ||
}, | ||
{ | ||
name: 'Reason', | ||
value: reason | ||
}, | ||
{ | ||
name: 'From bot /ban command', | ||
name: 'From Bot', | ||
value: 'true' | ||
} | ||
); | ||
eventLogEmbed.setFooter({ | ||
text: 'Pretendo Network', | ||
iconURL: guild.iconURL() | ||
}); | ||
eventLogEmbed.setThumbnail('attachment://mod-ban.png'); | ||
|
||
await util.sendEventLogMessage(guild, null, eventLogEmbed); | ||
await util.sendEventLogMessage('channels.mod-logs', guild, null, eventLogEmbed, image, null); | ||
|
||
const { count, rows } = await Bans.findAndCountAll({ | ||
const { count } = await Bans.findAndCountAll({ | ||
where: { | ||
user_id: member.id | ||
} | ||
}); | ||
|
||
const sendMemberEmbeds = []; | ||
|
||
|
||
const banEmbed = new Discord.MessageEmbed(); | ||
|
||
banEmbed.setTitle('Punishment Details'); | ||
banEmbed.setTitle('_Member Banned_'); | ||
banEmbed.setDescription('You have been banned from the Pretendo Network server. You may not rejoin at this time, and an appeal may not be possible\nYou may review the details of your ban below'); | ||
banEmbed.setColor(0xF24E43); | ||
banEmbed.setThumbnail('attachment://mod-ban.png'); | ||
banEmbed.setColor(0xa30000); | ||
banEmbed.setTimestamp(Date.now()); | ||
banEmbed.setAuthor({ | ||
name: `Banned by: ${executingMember.user.tag}`, | ||
iconURL: executingMember.user.avatarURL() | ||
}); | ||
banEmbed.setFooter({ | ||
text: 'Pretendo Network', | ||
iconURL: guild.iconURL() | ||
}); | ||
banEmbed.setFields({ | ||
name: 'Ban Reason', | ||
value: reason | ||
}, | ||
{ | ||
name: 'Amount Of Times Banned', | ||
value: (count + 1).toString() | ||
}); | ||
|
||
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); | ||
} | ||
|
||
Comment on lines
-97
to
-134
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. What possible errors? Can you be more specific? |
||
await member.send({ | ||
embeds: sendMemberEmbeds | ||
embeds: [banEmbed], | ||
files: [image] | ||
}).catch(() => console.log('Failed to DM user')); | ||
|
||
await member.ban({ | ||
|
@@ -146,10 +123,17 @@ async function banHandler(interaction) { | |
reason: reason | ||
}); | ||
|
||
bansListEmbed.setDescription(`${user.username} has been successfully banned`) | ||
bansListEmbed.addField(`${member.user.username}'s bans`, (count + 1).toString(), true); | ||
bansListEmbed.setFooter({ | ||
text: 'Pretendo Network', | ||
iconURL: guild.iconURL() | ||
}); | ||
bansListEmbed.setTimestamp(Date.now()); | ||
|
||
} | ||
|
||
await interaction.editReply({ embeds: [bansListEmbed], ephemeral: true }); | ||
await interaction.editReply({ embeds: [bansListEmbed], files: [image], ephemeral: true }); | ||
} | ||
|
||
const command = new SlashCommandBuilder() | ||
|
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.