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