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
+6 -4
View File
@@ -81,18 +81,20 @@ don't grant that permission.
- **View Channels** is required for every single command to work.
- **Send Messages** is required for every single command to work.
- **Manage Messages** allows Xiao to use the `prune` command.
* It also allows the `say` command to delete your message, but the command will still work without it.
- **Embed Links** is required to allow commands that send embeds to work. Too many commands to list use it.
- **Attach Files** is required to allow commands that send files to work. Too many commands to list use it.
- **Read Message History** allows Xiao to use the `first-message` and `prune` commands.
* It is also required to allow Xiao to react to messages alongside "Add Reactions".
- **Use External Emojis** allows Xiao to use custom emoji in certain commands.
* While the commands benefit from it, it is not required for the commands to work.
- **Add Reactions** allows Xiao to use commands that add reactions to messages in certain commands.
* While the commands benefit from it, it is not requried for the commands to work.
- **Connect** allows Xiao to connect to voice channels. This is needed for commands in the "Voice-Based" group.
- **Speak** allows Xiao to speak in voice channels. This is needed for commands in the "Voice-Based" group.
* While the commands benefit from it, it is not required for the commands to work.
* "Read Message History" is also required to allow Xiao to react.
- **Connect** allows Xiao to connect to voice channels. This is needed for commands that play audio.
- **Speak** allows Xiao to speak in voice channels. This is needed for commands that play audio.
- **Use Voice Activity** is not _needed_, but is included as an extra precaution for voice commands.
## Fun Information
- 500+ commands
+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, {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "121.3.0",
"version": "121.3.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+1 -1
View File
@@ -250,7 +250,7 @@ module.exports = class Util {
if (joined.includes(res.author.id)) return false;
if (res.content.toLowerCase() !== 'join game') return false;
joined.push(res.author.id);
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
Util.reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
return true;
};
const verify = await msg.channel.awaitMessages(filter, { max: max - 1, time: 60000 });