From 57fe0be1c8cc8325a5200d11deb402b0959191ff Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 20 Jun 2020 00:03:09 +0300 Subject: [PATCH] limitedResponse --- structure/extensions/Message.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/structure/extensions/Message.js b/structure/extensions/Message.js index c76fbe6..74dcef1 100644 --- a/structure/extensions/Message.js +++ b/structure/extensions/Message.js @@ -1,7 +1,6 @@ const { Structures } = require('discord.js'); const escapeRegex = require('escape-string-regexp'); -const emojis = require('../../util/emojis.json'); const { Util, Emojis } = require('../../util/'); const { stripIndents } = require('common-tags') @@ -88,7 +87,7 @@ const Message = Structures.extend('Message', (Message) => { if(typeof str === 'string') { if(opts.emoji) { - const emoji = emojis[opts.emoji]; + const emoji = Emojis[opts.emoji]; if(!emoji) this.command.client.logger.warn(`Invalid emoji provided to command ${this.command.resolveable}: "${opts.emoji}".`); str = `${emoji} ${str}`; } @@ -101,10 +100,25 @@ const Message = Structures.extend('Message', (Message) => { } + async limitedRespond(str, opts = { attachments: [] }) { + + if(typeof str === 'string') { + if(opts.emoji) { + const emoji = Emojis[opts.emoji]; + if(!emoji) this.client.logger.warn(`Invalid emoji provided to command ${this.command.resolveable}: "${opts.emoji}".`); + str = `${emoji} ${str}`; + } + if(opts.reply) str = `<@!${this.author.id}> ${str}`; + } + + return this.client.rateLimiter.limitSend(this.channel, str, opts.limit, opts.utility); + + } + async edit(str, opts) { if(!this.editable) return null; if(typeof str === 'string') { - if(opts.emoji) str = `${emojis[opts.emoji]} ${str}`; + if(opts.emoji) str = `${Emojis[opts.emoji]} ${str}`; if(opts.reply) str = `<@!${this.author.id}> ${str}`; } return super.edit(str); @@ -112,7 +126,7 @@ const Message = Structures.extend('Message', (Message) => { async prompt(str, opts) { if(typeof str === 'string') { - if(opts.emoji) str = `${emojis[opts.emoji]} ${str}`; + if(opts.emoji) str = `${Emojis[opts.emoji]} ${str}`; if(opts.reply) str = `<@!${this.author.id}> ${str}`; } await this.channel.send(str);