combine messageUtil and functions
This commit is contained in:
parent
f005efc454
commit
4c3e5e635c
2 changed files with 26 additions and 35 deletions
|
@ -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;
|
|
@ -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;
|
Loading…
Reference in a new issue