-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from aternosorg/similarmessages
/similarmessages
- Loading branch information
Showing
4 changed files
with
80 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/commands/settings/similarmessages/DisableSimilarMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const SubCommand = require('../../SubCommand'); | ||
|
||
class DisableSimilarMessages extends SubCommand { | ||
static names = ['disable', 'off']; | ||
|
||
static description = 'Disable repeated message protection.'; | ||
|
||
async execute() { | ||
this.guildConfig.similarMessages = -1; | ||
await this.guildConfig.save(); | ||
await this.reply('Disabled repeated message protection!'); | ||
} | ||
} | ||
|
||
module.exports = DisableSimilarMessages; |
16 changes: 16 additions & 0 deletions
16
src/commands/settings/similarmessages/GetSimilarMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const GetConfigCommand = require('../../GetConfigCommand'); | ||
|
||
class GetSimilarMessages extends GetConfigCommand { | ||
static names = ['get','show']; | ||
|
||
async execute() { | ||
if (this.guildConfig.similarMessages === -1) { | ||
await this.reply('Repeated message protection is currently disabled'); | ||
} | ||
else { | ||
await this.reply(`Repeated message protection is set to ${this.guildConfig.similarMessages} similar messages per minute.`); | ||
} | ||
} | ||
} | ||
|
||
module.exports = GetSimilarMessages; |
39 changes: 39 additions & 0 deletions
39
src/commands/settings/similarmessages/SetSimilarMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const SetConfigCommand = require('../../SetConfigCommand'); | ||
|
||
class SetSimilarMessages extends SetConfigCommand { | ||
static usage = '<limit>'; | ||
|
||
static description = 'Amount of similar messages users are allowed to send per minute.'; | ||
|
||
async execute() { | ||
const count = this.options.getInteger('count'); | ||
if (!Number.isNaN(count) && count > 0 && count <= 60) { | ||
this.guildConfig.similarMessages = count; | ||
await this.guildConfig.save(); | ||
await this.reply(`Enabled repeated message protection! Users can now only send ${count} similar messages per minute.`); | ||
} else { | ||
await this.sendUsage(); | ||
} | ||
} | ||
|
||
static getOptions() { | ||
return [{ | ||
name: 'count', | ||
type: 'INTEGER', | ||
description: 'Similar messages limit.', | ||
required: true, | ||
minValue: 1, | ||
maxValue: 60, | ||
}]; | ||
} | ||
|
||
parseOptions(args) { | ||
return [{ | ||
type: 'INTEGER', | ||
name: 'count', | ||
value: parseInt(args.shift()) | ||
}]; | ||
} | ||
} | ||
|
||
module.exports = SetSimilarMessages; |