mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 18:39:35 +02:00
Only continue if it's valid
This commit is contained in:
+12
-3
@@ -1,4 +1,6 @@
|
||||
const { promisify } = require('util');
|
||||
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea'];
|
||||
const no = ['no', 'n', 'nah', 'nope'];
|
||||
|
||||
class Util {
|
||||
static wait(time) {
|
||||
@@ -92,12 +94,19 @@ class Util {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static async verify(channel, user, time = 30000) {
|
||||
const verify = await channel.awaitMessages(res => res.author.id === user.id, {
|
||||
static verify(channel, user, time = 30000) {
|
||||
const filter = res => {
|
||||
const value = res.content.toLowerCase();
|
||||
return res.author.id === user.id && (yes.includes(value) || no.includes(value));
|
||||
};
|
||||
const verify = await channel.awaitMessages(filter, {
|
||||
max: 1,
|
||||
time
|
||||
});
|
||||
return verify.size && ['yes', 'y', 'ye', 'yeah', 'yup'].includes(verify.first().content.toLowerCase());
|
||||
if (!verify.size) return false;
|
||||
const choice = verify.first().content.toLowerCase();
|
||||
if (yes.includes(choice)) return true;
|
||||
if (no.includes(choice)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user