Convert all react methods to reactIfAble

This commit is contained in:
Dragon Fire
2020-11-26 11:44:51 -05:00
parent cd166dce0e
commit c31fd9151e
10 changed files with 23 additions and 20 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const Collection = require('@discordjs/collection');
const { stripIndents } = require('common-tags');
const { awaitPlayers } = require('../../util/Util');
const { awaitPlayers, reactIfAble } = require('../../util/Util');
const nums = require('../../assets/json/bingo');
const { SUCCESS_EMOJI_ID } = process.env;
const rows = Object.keys(nums);
@@ -73,7 +73,7 @@ module.exports = class BingoCommand extends Command {
if (!players.has(res.author.id)) return false;
if (res.content.toLowerCase() === 'leave game') {
players.delete(res.author.id);
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
if (!players.size) return true;
return false;
}
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const Collection = require('@discordjs/collection');
const { delay, awaitPlayers } = require('../../util/Util');
const { delay, awaitPlayers, reactIfAble } = require('../../util/Util');
const questions = require('../../assets/json/guesspionage');
const { SUCCESS_EMOJI_ID } = process.env;
const guesses = ['much higher', 'higher', 'lower', 'much lower'];
@@ -112,7 +112,7 @@ module.exports = class GuesspionageCommand extends Command {
if (!awaitedPlayers.includes(res.author.id)) return false;
if (!guesses.includes(res.content.toLowerCase())) return false;
guessed.push(res.author.id);
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
};
const everyoneElse = await msg.channel.awaitMessages(everyoneElseFilter, {
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { stripIndents, oneLine } = require('common-tags');
const Collection = require('@discordjs/collection');
const { delay, awaitPlayers, list } = require('../../util/Util');
const { delay, awaitPlayers, list, reactIfAble } = require('../../util/Util');
const words = require('../../assets/json/imposter');
const { SUCCESS_EMOJI_ID } = process.env;
@@ -114,7 +114,7 @@ module.exports = class ImposterCommand extends Command {
votes: currentVotes ? currentVotes + 1 : 1,
id: ids[int - 1]
});
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
}
return false;
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const Collection = require('@discordjs/collection');
const { delay, awaitPlayers } = require('../../util/Util');
const { delay, awaitPlayers, reactIfAble } = require('../../util/Util');
const { SUCCESS_EMOJI_ID } = process.env;
module.exports = class IslandCommand extends Command {
@@ -71,7 +71,7 @@ module.exports = class IslandCommand extends Command {
votes: currentVotes ? currentVotes + 1 : 1,
id: ids[int - 1]
});
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
}
return false;
+2 -2
View File
@@ -2,7 +2,7 @@ const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
const Collection = require('@discordjs/collection');
const { delay, awaitPlayers } = require('../../util/Util');
const { delay, awaitPlayers, reactIfAble } = require('../../util/Util');
const { SUCCESS_EMOJI_ID } = process.env;
const trueOptions = ['true', 'yes', 'the truth', 't', 'tru', 'tr', 'y', 'ye'];
const falseOptions = ['false', 'lie', 'no', 'a lie', 'f', 'fals', 'fal', 'fa', 'n', 'l'];
@@ -71,7 +71,7 @@ module.exports = class LieSwatterCommand extends Command {
if (!awaitedPlayers.includes(res.author.id)) return false;
const answer = res.content.toLowerCase();
if (trueOptions.includes(answer) || falseOptions.includes(answer)) {
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
}
return false;
+2 -2
View File
@@ -2,7 +2,7 @@ const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
const Collection = require('@discordjs/collection');
const { delay, awaitPlayers, shuffle } = require('../../util/Util');
const { delay, awaitPlayers, shuffle, reactIfAble } = require('../../util/Util');
const { SUCCESS_EMOJI_ID } = process.env;
const choices = ['A', 'B', 'C', 'D'];
@@ -64,7 +64,7 @@ module.exports = class QuizDuelCommand extends Command {
if (!awaitedPlayers.includes(res.author.id)) return false;
const answer = res.content.toUpperCase();
if (choices.includes(answer)) {
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
}
return false;
+3 -2
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const request = require('node-superfetch');
const { reactIfAble } = require('../../util/Util');
const scores = require('../../assets/json/anagramica');
const pool = 'abcdefghijklmnopqrstuvwxyz'.split('');
const { SUCCESS_EMOJI_ID, FAILURE_EMOJI_ID } = process.env;
@@ -54,12 +55,12 @@ module.exports = class AnagramicaCommand extends Command {
if (!valid.includes(res.content.toLowerCase())) {
points -= score;
picked.push(res.content.toLowerCase());
res.react(FAILURE_EMOJI_ID || '❌').catch(() => null);
reactIfAble(res, res.author, FAILURE_EMOJI_ID, '❌');
return false;
}
points += score;
picked.push(res.content.toLowerCase());
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
};
const msgs = await msg.channel.awaitMessages(filter, {