From 4c3e5e635cac3c94ad1a4daebf9c01a2733c929f Mon Sep 17 00:00:00 2001 From: Emily J Date: Thu, 8 Oct 2020 13:06:06 +1100 Subject: [PATCH] combine messageUtil and functions --- bot/util/functions.js | 26 ++++++++++++++++++++++++++ bot/util/messageUtil.js | 35 ----------------------------------- 2 files changed, 26 insertions(+), 35 deletions(-) delete mode 100644 bot/util/messageUtil.js diff --git a/bot/util/functions.js b/bot/util/functions.js index 51e95ee..d2d23e7 100644 --- a/bot/util/functions.js +++ b/bot/util/functions.js @@ -38,7 +38,33 @@ class Functions { return Math.round((Math.random() * (max - min))+min); } + // Grab the last message sent in a channel (excludes the command) + async getLastMessage (channel) { + if (channel) { + let lastMsg; + await channel.messages.fetch({ limit: 2 }).then(messages => { + lastMsg = messages.last().content; + }); + return lastMsg; + } + } + + // Wait for a reply to a message, then pass through the response + async awaitReply (msg, question, limit = 60000) { + const filter = m => m.author.id === msg.author.id; + await msg.channel.send(question); + try { + const collected = await msg.channel.awaitMessages(filter, { + max: 1, + time: limit, + errors: ["time"] + }); + return collected.first().content; + } catch (e) { + return false; + } + } } module.exports = Functions; \ No newline at end of file diff --git a/bot/util/messageUtil.js b/bot/util/messageUtil.js deleted file mode 100644 index 817281c..0000000 --- a/bot/util/messageUtil.js +++ /dev/null @@ -1,35 +0,0 @@ -class MessageUtil { - constructor (client) { - this.client = client; - } - - // Grab the last message sent in a channel (excludes the command) - async getLastMessage (channel) { - if (channel) { - let lastMsg; - - await channel.messages.fetch({ limit: 2 }).then(messages => { - lastMsg = messages.last().content; - }); - return lastMsg; - } - } - - // Wait for a reply to a message, then pass through the response - async awaitReply (msg, question, limit = 60000) { - const filter = m => m.author.id === msg.author.id; - await msg.channel.send(question); - try { - const collected = await msg.channel.awaitMessages(filter, { - max: 1, - time: limit, - errors: ["time"] - }); - return collected.first().content; - } catch (e) { - return false; - } - } -} - -module.exports = MessageUtil; \ No newline at end of file