From 81b06223459716e6cc855f824f10086b9b17cb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Thu, 20 Aug 2020 13:03:16 -0400 Subject: [PATCH 1/5] add slowmode to src/commands/index.ts --- src/commands/index.ts | 61 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/commands/index.ts b/src/commands/index.ts index 0f3d8d9..a4d0f26 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,30 +1,31 @@ -export { default as additem } from './additem'; -export { default as addnote } from './addnote'; -export { default as addrank } from './addrank'; -export { default as addredirect } from './addredirect'; -export { default as ban } from './ban'; -export { default as delitem } from './delitem'; -export { default as delnote } from './delnote'; -export { default as delrank } from './delrank'; -export { default as delredirect } from './delredirect'; -export { default as djs } from './djs'; -export { default as eris } from './eris'; -export { default as eval } from './eval'; -export { default as game } from './game'; -export { default as help } from './help'; -export { default as info } from './info'; -export { default as kick } from './kick'; -export { default as listredirects } from './listredirects'; -export { default as members } from './members'; -export { default as mute } from './mute'; -export { default as notes } from './notes'; -export { default as npm } from './npm'; -export { default as page } from './page'; -export { default as ping } from './ping'; -export { default as rank } from './rank'; -export { default as roleinfo } from './roleinfo'; -export { default as stats } from './stats'; -export { default as storemessages } from './storemessages'; -export { default as unban } from './unban'; -export { default as unmute } from './unmute'; -export { default as whois } from './whois'; +export { default as additem } from './additem'; +export { default as addnote } from './addnote'; +export { default as addrank } from './addrank'; +export { default as addredirect } from './addredirect'; +export { default as ban } from './ban'; +export { default as delitem } from './delitem'; +export { default as delnote } from './delnote'; +export { default as delrank } from './delrank'; +export { default as delredirect } from './delredirect'; +export { default as djs } from './djs'; +export { default as eris } from './eris'; +export { default as eval } from './eval'; +export { default as game } from './game'; +export { default as help } from './help'; +export { default as info } from './info'; +export { default as kick } from './kick'; +export { default as listredirects } from './listredirects'; +export { default as members } from './members'; +export { default as mute } from './mute'; +export { default as notes } from './notes'; +export { default as npm } from './npm'; +export { default as page } from './page'; +export { default as ping } from './ping'; +export { default as rank } from './rank'; +export { default as roleinfo } from './roleinfo'; +export { default as slowmode } from './slowmode'; +export { default as stats } from './stats'; +export { default as storemessages } from './storemessages'; +export { default as unban } from './unban'; +export { default as unmute } from './unmute'; +export { default as whois } from './whois'; From c04d6cddc803231cd5eba55e5e65f65da0830a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Thu, 20 Aug 2020 13:04:25 -0400 Subject: [PATCH 2/5] added slowmode.ts --- src/commands/slowmode.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/commands/slowmode.ts diff --git a/src/commands/slowmode.ts b/src/commands/slowmode.ts new file mode 100644 index 0000000..00e2490 --- /dev/null +++ b/src/commands/slowmode.ts @@ -0,0 +1,34 @@ +import { Message, GuildTextableChannel } from 'eris'; +import moment, { unitOfTime } from 'moment'; +import { Client, Command } from '../class'; + +export default class Slowmode extends Command { + regex: RegExp; + + constructor(client: Client) { + super(client); + this.name = 'slowmode'; + this.description = 'Set slowmode to a channel.'; + this.usage = 'slowmode '; + this.permissions = 1; + this.guildOnly = true; + this.enabled = true; + this.regex = /[a-z]+|[^a-z]+/gi; + } + + public async run(message: Message, args: string[]) { + try { + if (!args[0]) return this.error(message.channel, 'This command requires an argument.'); + + const [length, unit] = args[0].match(this.regex); + if (Number.isNaN(Number(length))) return this.error(message.channel, 'Could not determine the slowmode time.'); + const momentSeconds: number = Math.round(moment.duration(length, unit as unitOfTime.Base || 's').asSeconds()); + + if (momentSeconds > 21600 || momentSeconds < 0) return this.error(message.channel, 'Slowmode must be between 0 seconds and 6 hours.'); + + return message.channel.edit({ rateLimitPerUser: momentSeconds }).then((c) => message.addReaction(':success:477618704155410452')); + } catch (err) { + return this.client.util.handleError(err, message, this); + } + } +} From 0e149a6ad9b3fe0216a66ceef8ef57551ab6618c Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 5 Mar 2021 17:30:32 -0500 Subject: [PATCH 5/5] fix to slowmode cmd --- src/commands/slowmode.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/slowmode.ts b/src/commands/slowmode.ts index 00e2490..729ff89 100644 --- a/src/commands/slowmode.ts +++ b/src/commands/slowmode.ts @@ -18,7 +18,7 @@ export default class Slowmode extends Command { public async run(message: Message, args: string[]) { try { - if (!args[0]) return this.error(message.channel, 'This command requires an argument.'); + if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); const [length, unit] = args[0].match(this.regex); if (Number.isNaN(Number(length))) return this.error(message.channel, 'Could not determine the slowmode time.');