Skip to content

Commit

Permalink
Merge pull request #510 from aternosorg/caps
Browse files Browse the repository at this point in the history
fix caps moderation, 3.0.2
  • Loading branch information
JulianVennen authored Oct 25, 2022
2 parents 5e4b7f5 + a0045a1 commit c2e7b66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "modbot",
"version": "3.0.1",
"version": "3.0.2",
"description": "Discord Bot for the Aternos Discord server",
"main": "index.js",
"type": "module",
Expand Down
23 changes: 14 additions & 9 deletions src/automod/AutoModManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class AutoModManager {
if (!message.guild || message.system || message.author.bot) {
return true;
}
const guildconfig = await GuildSettings.get(message.guild.id);
return message.member.permissions.has(PermissionFlagsBits.ManageMessages) || guildconfig.isProtected(message.member);
const guildSettings = await GuildSettings.get(message.guild.id);
return message.member.permissions.has(PermissionFlagsBits.ManageMessages) || guildSettings.isProtected(message.member);
}

/**
Expand Down Expand Up @@ -182,6 +182,11 @@ export class AutoModManager {
* @return {Promise<boolean>} has the message been deleted
*/
async #caps(message) {
const guildSettings = await GuildSettings.get(message.guild.id);
if (!guildSettings.caps) {
return false;
}

const uppercase = (message.content.match(/[A-Z]/g) ?? []).length;
const lowercase = (message.content.match(/[a-z]/g) ?? []).length;

Expand All @@ -201,9 +206,9 @@ export class AutoModManager {
return false;
}

const guildConfig = await GuildSettings.get(message.guild.id);
const channelConfig = await ChannelSettings.get(message.channel.id);
const allowed = channelConfig.invites ?? guildConfig.invites;
const guildSettings = await GuildSettings.get(message.guild.id);
const channelSettings = await ChannelSettings.get(message.channel.id);
const allowed = channelSettings.invites ?? guildSettings.invites;

if (allowed) {
return false;
Expand Down Expand Up @@ -274,16 +279,16 @@ export class AutoModManager {
* @return {Promise<boolean>}
*/
async spam(message) {
const guildConfig = await GuildSettings.get(message.guild.id);
if (guildConfig.antiSpam === -1 && guildConfig.similarMessages === -1) {
const guildSettings = await GuildSettings.get(message.guild.id);
if (guildSettings.antiSpam === -1 && guildSettings.similarMessages === -1) {
return false;
}

RepeatedMessage.add(message);
if (guildConfig.antiSpam !== -1 && await RepeatedMessage.checkSpam(message, guildConfig.antiSpam, this.#RESPONSE_TIMEOUT)) {
if (guildSettings.antiSpam !== -1 && await RepeatedMessage.checkSpam(message, guildSettings.antiSpam, this.#RESPONSE_TIMEOUT)) {
return await this.#deleteAndWarn(message, 'Sending messages to quickly', 'Slow down, you\'re sending messages to quickly!');
}
else if (guildConfig.similarMessages !== -1 && await RepeatedMessage.checkSimilar(message, guildConfig.similarMessages, this.#RESPONSE_TIMEOUT)) {
else if (guildSettings.similarMessages !== -1 && await RepeatedMessage.checkSimilar(message, guildSettings.similarMessages, this.#RESPONSE_TIMEOUT)) {
return await this.#deleteAndWarn(message, 'Repeating messages', 'Stop repeating your messages!');
}
return false;
Expand Down

0 comments on commit c2e7b66

Please sign in to comment.