Transfer Fidget Commands

This commit is contained in:
Dragon Fire
2018-07-17 22:10:14 -04:00
parent 68c89b1600
commit 0bed447766
13 changed files with 5038 additions and 3 deletions
+7 -1
View File
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
The bot is no longer available for invite. You can self-host the bot, or use her
on the [home server](https://discord.gg/sbMe32W).
## Commands (288)
## Commands (294)
### Utility:
* **eval**: Executes JavaScript code.
@@ -185,10 +185,12 @@ on the [home server](https://discord.gg/sbMe32W).
### Games:
* **akinator**: Think about a real or fictional character, I will try to guess who it is.
* **apples-to-apples**: Compete to see who can come up with the best card to match an adjective.
* **balloon-pop**: Don't let yourself be the last one to pump the balloon before it pops!
* **battle**: Engage in a turn-based battle against another user or the AI.
* **box-choosing**: Do you believe that there are choices in life? Taken from Higurashi Chapter 4.
* **captcha-quiz**: Try to guess what the captcha says.
* **cards-against-humanity**: Compete to see who can come up with the best card to fill in the blank.
* **chance**: Attempt to win with a 1 in 1000 (or your choice) chance of winning.
* **emoji-emoji-revolution**: Can you type arrow emoji faster than anyone else has ever typed them before?
* **fishy**: Go fishing.
@@ -197,6 +199,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **hangman**: Prevent a man from being hanged by guessing a word as fast as you can.
* **hunger-games**: Simulate a Hunger Games match with up to 24 tributes.
* **lottery**: Attempt to win the lottery with 6 numbers.
* **mafia**: Who is the Mafia? Who is the doctor? Who is the detective? Will the Mafia kill them all?
* **math-quiz**: See how fast you can answer a math problem in a given time limit.
* **quiz**: Answer a quiz question.
* **rock-paper-scissors**: Play Rock-Paper-Scissors.
@@ -205,6 +208,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **sorting-hat-quiz**: Take a quiz to determine your Hogwarts house.
* **tic-tac-toe**: Play a game of tic-tac-toe with another user.
* **typing-test**: See how fast you can type a sentence in a given time limit.
* **wizard-convention**: Who is the Dragon? Who is the healer? Who is the mind reader? Will the Dragon eat them all?
* **whos-that-pokemon**: Guess who that Pokémon is.
### Voice Channel:
@@ -305,6 +309,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **translate**: Translates text to a specific language.
* **upside-down**: Flips text upside-down.
* **url-encode**: Encodes text to URL-friendly characters.
* **webhook**: Posts a message to the webhook defined in your `process.env`.
* **yoda**: Converts text to Yoda speak.
* **zalgo**: Converts text to zalgo.
* **🅱**: Replaces b with 🅱.
@@ -327,6 +332,7 @@ on the [home server](https://discord.gg/sbMe32W).
### Other:
* **cleverbot**: Chat with Cleverbot.
* **prune**: Deletes up to 99 messages from the current channel.
* **strawpoll**: Generates a Strawpoll with the options you provide.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
{
"questions": {
"mafia": "Who do you want to kill?",
"doctor": "Who do you want to save?",
"detective": "Who do you think is the Mafia?"
},
"stories": [
".",
" after they had left to get a little snack.",
" while they were in the library reading a story.",
" before they could get the chance to call 911.",
" while they were trying to sneak into someone's house.",
" when they left for a bathroom break.",
" with one bullet.",
" while they were making a very early coffee.",
" while they were attemping to flirt with the Mafia member.",
", who willingly accepted their fate.",
" while they were playing a quick game of Mafia online like a loner.",
" while they were writing a letter to the president.",
" before they could have the chance to fight back.",
" just as they were about to get ready to leave in fear.",
", who was a complete coward and was killed while screaming.",
", who had no time to run.",
", who was busy trying to find the Mafia.",
" with almost no sign of any remains.",
" before they could even mutter a word.",
", who left a large mess in the kitchen."
]
}
+29
View File
@@ -0,0 +1,29 @@
{
"questions": {
"dragon": "Who do you want to eat?",
"healer": "Who do you want to heal?",
"mind reader": "Who do you think is the dragon?"
},
"stories": [
".",
" after they had left to get a little snack.",
" while they were in the library fixing their wand.",
" before they could get the chance to call for help.",
" while they were trying to sneak into another wizard's room.",
" when they left for the bathroom.",
" in one big bite.",
" while they were making a very early coffee.",
" while they were attemping to flirt with it.",
", who willingly accepted their fate.",
" while they were playing a quick game of Wizard Convention.",
" while they were writing a letter to the king.",
" before they could have the chance to fight back.",
" just as they were about to get ready to leave in fear.",
", who was a complete coward and turned into a chicken at the sight of the beast.",
", who had no time to run.",
", who was busy trying to find the rumored dragon of the convention.",
" with almost no sign of any remains.",
" before they could even mutter a word.",
", who left a large mess in the kitchen."
]
}
+168
View File
@@ -0,0 +1,168 @@
const Command = require('../../structures/Command');
const { escapeMarkdown } = require('discord.js');
const { stripIndents } = require('common-tags');
const { shuffle, awaitPlayers } = require('../../util/Util');
const { greenCards, redCards } = require('../../assets/json/apples-to-apples');
module.exports = class ApplesToApplesCommand extends Command {
constructor(client) {
super(client, {
name: 'apples-to-apples',
group: 'games',
memberName: 'apples-to-apples',
description: 'Compete to see who can come up with the best card to match an adjective.',
guildOnly: true,
args: [
{
key: 'maxPts',
label: 'maximum amount of points',
prompt: 'What amount of points should determine the winner?',
type: 'integer',
min: 1,
max: 20
}
]
});
this.playing = new Set();
}
async run(msg, { maxPts }) {
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
this.playing.add(msg.channel.id);
try {
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
const awaitedPlayers = await awaitPlayers(msg, 10, 3);
if (!awaitedPlayers) {
this.playing.delete(msg.channel.id);
return msg.say('Game could not be started...');
}
const players = await this.generatePlayers(awaitedPlayers);
const czars = Array.from(players.values());
let winner = null;
while (!winner) {
const czar = czars[0];
czars.push(czar);
czars.shift();
const green = greenCards[Math.floor(Math.random() * greenCards.length)];
await msg.say(stripIndents`
The card czar will be ${czar.user}!
The Green Card is: **${escapeMarkdown(green)}**
Sending DMs...
`);
const chosenCards = [];
for (const player of players.values()) {
if (player.hand.size < 11) {
const valid = redCards.filter(card => !player.hand.has(card));
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
}
if (player.user.id === czar.user.id) continue;
if (!player.hand.size) {
await player.user.send('You don\'t have enough cards!');
continue;
}
const hand = Array.from(player.hand);
await player.user.send(stripIndents`
__**Your hand is**__:
${hand.map((card, i) => `**${i + 1}.** ${card}`).join('\n')}
**Green Card**: ${escapeMarkdown(green)}
**Card Czar**: ${czar.user.username}
Pick **1** card!
`);
let chosen = null;
const filter = res => {
const existing = hand[Number.parseInt(res.content, 10) - 1];
if (!existing) return false;
chosen = existing;
return true;
};
const choice = await player.user.dmChannel.awaitMessages(filter, {
max: 1,
time: 120000
});
if (!choice.size) {
await player.user.send('Skipping your turn...');
continue;
}
if (chosen === '<Blank>') {
const handled = await this.handleBlank(player);
chosen = handled;
} else {
player.hand.delete(chosen);
}
chosenCards.push({
id: player.id,
card: chosen
});
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
}
if (!chosenCards.length) {
await msg.say('Hmm... No one even tried.');
break;
}
const cards = shuffle(chosenCards);
await msg.say(stripIndents`
${czar.user}, which card do you pick?
**Green Card**: ${escapeMarkdown(green)}
${cards.map((card, i) => `**${i + 1}.** ${card.card}`).join('\n')}
`);
const filter = res => {
if (res.author.id !== czar.user.id) return false;
if (!cards[Number.parseInt(res.content, 10) - 1]) return false;
return true;
};
const chosen = await msg.channel.awaitMessages(filter, {
max: 1,
time: 120000
});
if (!chosen.size) {
await msg.say('Hmm... No one wins.');
continue;
}
const player = players.get(cards[Number.parseInt(chosen.first().content, 10) - 1].id);
++player.points;
if (player.points >= maxPts) winner = player.user;
else await msg.say(`Nice one, ${player.user}! You now have **${player.points}** points!`);
}
this.playing.delete(msg.channel.id);
if (!winner) return msg.say('See you next time!');
return msg.say(`And the winner is... ${winner}! Great job!`);
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async generatePlayers(list) {
const players = new Map();
for (const user of list) {
const cards = new Set();
for (let i = 0; i < 5; i++) {
const valid = redCards.filter(card => !cards.has(card));
cards.add(valid[Math.floor(Math.random() * valid.length)]);
}
players.set(user.id, {
id: user.id,
user,
points: 0,
hand: cards
});
await user.send('Hi! Waiting for your turn to start...');
}
return players;
}
async handleBlank(player) {
await player.user.send('What do you want the blank card to say? Must be 100 or less characters.');
const blank = await player.user.dmChannel.awaitMessages(res => res.content.length <= 100, {
max: 1,
time: 120000
});
player.hand.delete('<Blank>');
if (!blank.size) return `A blank card ${player.user.tag} forgot to fill out.`;
return blank.first().content;
}
};
+169
View File
@@ -0,0 +1,169 @@
const Command = require('../../structures/Command');
const { escapeMarkdown } = require('discord.js');
const { stripIndents } = require('common-tags');
const { shuffle, awaitPlayers } = require('../../util/Util');
const { blackCards, whiteCards } = require('../../assets/json/cards-against-humanity');
module.exports = class CardsAgainstHumanityCommand extends Command {
constructor(client) {
super(client, {
name: 'cards-against-humanity',
aliases: ['crude-cards', 'pretend-youre-xyzzy', 'cah'],
group: 'games',
memberName: 'cards-against-humanity',
description: 'Compete to see who can come up with the best card to fill in the blank.',
guildOnly: true,
args: [
{
key: 'maxPts',
label: 'maximum amount of points',
prompt: 'What amount of points should determine the winner?',
type: 'integer',
min: 1,
max: 20
}
]
});
this.playing = new Set();
}
async run(msg, { maxPts }) {
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
this.playing.add(msg.channel.id);
try {
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
const awaitedPlayers = await awaitPlayers(msg, 10, 3);
if (!awaitedPlayers) {
this.playing.delete(msg.channel.id);
return msg.say('Game could not be started...');
}
const players = await this.generatePlayers(awaitedPlayers);
const czars = Array.from(players.values());
let winner = null;
while (!winner) {
const czar = czars[0];
czars.push(czar);
czars.shift();
const black = blackCards[Math.floor(Math.random() * blackCards.length)];
await msg.say(stripIndents`
The card czar will be ${czar.user}!
The Black Card is: **${escapeMarkdown(black.text)}**
Sending DMs...
`);
const chosenCards = [];
for (const player of players.values()) {
if (player.hand.size < 11) {
const valid = whiteCards.filter(card => !player.hand.has(card));
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
}
if (player.user.id === czar.user.id) continue;
if (player.hand.size < black.pick) {
await player.user.send('You don\'t have enough cards!');
continue;
}
const hand = Array.from(player.hand);
await player.user.send(stripIndents`
__**Your hand is**__:
${hand.map((card, i) => `**${i + 1}.** ${card}`).join('\n')}
**Black Card**: ${escapeMarkdown(black.text)}
**Card Czar**: ${czar.user.username}
Pick **${black.pick}** card${black.pick > 1 ? 's' : ''}!
`);
const chosen = [];
const filter = res => {
const existing = hand[Number.parseInt(res.content, 10) - 1];
if (!existing) return false;
if (chosen.includes(existing)) return false;
chosen.push(existing);
return true;
};
const choices = await player.user.dmChannel.awaitMessages(filter, {
max: black.pick,
time: 120000
});
if (!choices.size || choices.size < black.pick) {
await player.user.send('Skipping your turn...');
continue;
}
if (chosen.includes('<Blank>')) {
const handled = await this.handleBlank(player);
chosen[chosen.indexOf('<Blank>')] = handled;
}
for (const card of chosen) player.hand.delete(card);
chosenCards.push({
id: player.id,
cards: chosen
});
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
}
if (!chosenCards.length) {
await msg.say('Hmm... No one even tried.');
break;
}
const cards = shuffle(chosenCards);
await msg.say(stripIndents`
${czar.user}, which card${black.pick > 1 ? 's' : ''} do you pick?
**Black Card**: ${escapeMarkdown(black.text)}
${cards.map((card, i) => `**${i + 1}.** ${card.cards.join(', ')}`).join('\n')}
`);
const filter = res => {
if (res.author.id !== czar.user.id) return false;
if (!cards[Number.parseInt(res.content, 10) - 1]) return false;
return true;
};
const chosen = await msg.channel.awaitMessages(filter, {
max: 1,
time: 120000
});
if (!chosen.size) {
await msg.say('Hmm... No one wins.');
continue;
}
const player = players.get(cards[Number.parseInt(chosen.first().content, 10) - 1].id);
++player.points;
if (player.points >= maxPts) winner = player.user;
else await msg.say(`Nice one, ${player.user}! You now have **${player.points}** points!`);
}
this.playing.delete(msg.channel.id);
if (!winner) return msg.say('See you next time!');
return msg.say(`And the winner is... ${winner}! Great job!`);
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async generatePlayers(list) {
const players = new Map();
for (const user of list) {
const cards = new Set();
for (let i = 0; i < 5; i++) {
const valid = whiteCards.filter(card => !cards.has(card));
cards.add(valid[Math.floor(Math.random() * valid.length)]);
}
players.set(user.id, {
id: user.id,
user,
points: 0,
hand: cards
});
await user.send('Hi! Waiting for your turn to start...');
}
return players;
}
async handleBlank(player) {
await player.user.send('What do you want the blank card to say? Must be 100 or less characters.');
const blank = await player.user.dmChannel.awaitMessages(res => res.content.length <= 100, {
max: 1,
time: 120000
});
player.hand.delete('<Blank>');
if (!blank.size) return `A blank card ${player.user.tag} forgot to fill out.`;
return blank.first().content;
}
};
+163
View File
@@ -0,0 +1,163 @@
const Command = require('../../structures/Command');
const { Collection } = require('discord.js');
const { stripIndents } = require('common-tags');
const { shuffle, wait, awaitPlayers } = require('../../util/Util');
const { questions, stories } = require('../../assets/json/mafia');
module.exports = class MafiaCommand extends Command {
constructor(client) {
super(client, {
name: 'mafia',
aliases: ['town-of-salem', 'werewolf'],
group: 'games',
memberName: 'mafia',
description: 'Who is the Mafia? Who is the doctor? Who is the detective? Will the Mafia kill them all?',
guildOnly: true
});
this.playing = new Set();
}
async run(msg) { // eslint-disable-line complexity
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
this.playing.add(msg.channel.id);
try {
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
const awaitedPlayers = await awaitPlayers(msg, 10, 3);
if (!awaitedPlayers) {
this.playing.delete(msg.channel.id);
return msg.say('Game could not be started...');
}
const players = await this.generatePlayers(awaitedPlayers);
let turn = 1;
while (players.size > 2 && players.some(p => p.role === 'mafia')) {
let killed = null;
let saved = null;
await msg.say(`Night ${turn}, sending DMs...`);
for (const player of players.values()) {
if (player.role.includes('pleb')) continue;
await msg.say(`The ${player.role} is making their decision...`);
const valid = players.filterArray(p => p.role !== player.role);
await player.user.send(stripIndents`
${questions[player.role]} Please type the number.
${valid.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')}
`);
const filter = res => valid[Number.parseInt(res.content, 10) - 1];
const decision = await player.user.dmChannel.awaitMessages(filter, {
max: 1,
time: 120000
});
if (!decision.size) {
await player.user.send('Sorry, time is up!');
continue;
}
const choice = Number.parseInt(decision.first().content, 10);
if (player.role === 'mafia') {
const chosen = players.get(choice);
killed = chosen.id;
await player.user.send(`${chosen.user.tag} will be killed...`);
} else if (player.role === 'doctor') {
const chosen = players.get(choice);
saved = chosen.id;
await player.user.send(`${chosen.user.tag} will be saved...`);
} else if (player.role === 'detective') {
await player.user.send(players.find(p => p.role === 'mafia').id === choice ? 'Yes.' : 'No.');
}
}
const display = killed ? players.get(killed).user : null;
const story = stories[Math.floor(Math.random() * stories.length)];
if (killed && killed !== saved) players.delete(killed);
if (killed && killed === saved) {
await msg.say(stripIndents`
Late last night, a Mafia member emerged from the dark and tried to kill ${display}${story}
Thankfully, a doctor stepped in just in time to save the day.
Who is this mysterious Mafia member? You have one minute to decide.
`);
} else if (killed && players.size < 3) {
await msg.say(stripIndents`
Late last night, a Mafia member emerged from the dark and killed poor ${display}${story}
Sadly, after the event, the final citizen left the town in fear, leaving the Mafia to rule forever.
`);
break;
} else if (killed && killed !== saved) {
await msg.say(stripIndents`
Late last night, a Mafia member emerged from the dark and killed poor ${display}${story}
Who is this mysterious Mafia member? You have one minute to decide.
`);
} else {
await msg.say(stripIndents`
Late last night, a Mafia member emerged from the dark. Thankfully, however, they didn't try to kill anyone.
Who is this mysterious Mafia member? You have one minute to decide.
`);
}
await wait(60000);
const playersArr = Array.from(players.values());
await msg.say(stripIndents`
Who do you think is the Mafia member? Please type the number.
${playersArr.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')}
`);
const voted = [];
const filter = res => {
if (!players.exists(p => p.user.id === res.author.id)) return false;
if (voted.includes(res.author.id)) return false;
if (!playersArr[Number.parseInt(res.content, 10) - 1]) return false;
voted.push(res.author.id);
return true;
};
const votes = await msg.channel.awaitMessages(filter, {
max: players.size,
time: 120000
});
if (!votes.size) {
await msg.say('No one will be hanged.');
continue;
}
const hanged = this.getHanged(votes, players, playersArr);
await msg.say(`${hanged.user} will be hanged.`);
players.delete(hanged.id);
++turn;
}
this.playing.delete(msg.channel.id);
const mafia = players.find(p => p.role === 'mafia');
if (!mafia) return msg.say('The Mafia has been hanged! Thanks for playing!');
return msg.say(`Oh no, the Mafia wasn't caught in time... Nice job, ${mafia.user}!`);
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async generatePlayers(list) {
let roles = ['mafia', 'doctor', 'detective'];
for (let i = 0; i < (list.length - 2); i++) roles.push(`pleb ${i + 1}`);
roles = shuffle(roles);
const players = new Collection();
let i = 0;
for (const user of list) {
players.set(user.id, {
id: user.id,
user,
role: roles[i]
});
await user.send(`Your role will be: ${roles[i]}!`);
i++;
}
}
getHanged(votes, players, playersArr) {
const counts = new Collection();
for (const vote of votes.values()) {
const player = players.get(playersArr[Number.parseInt(vote.content, 10) - 1].id);
if (counts.has(player.id)) {
++counts.get(player.id).votes;
} else {
counts.set(player.id, {
id: player.id,
votes: 1,
user: player.user
});
}
}
return counts.sort((a, b) => b.votes - a.votes).first();
}
};
+163
View File
@@ -0,0 +1,163 @@
const Command = require('../../structures/Command');
const { Collection } = require('discord.js');
const { stripIndents } = require('common-tags');
const { shuffle, wait, awaitPlayers } = require('../../util/Util');
const { questions, stories } = require('../../assets/json/wizard-convention');
module.exports = class WizardConventionCommand extends Command {
constructor(client) {
super(client, {
name: 'wizard-convention',
aliases: ['wiz-convention'],
group: 'games',
memberName: 'wizard-convention',
description: 'Who is the Dragon? Who is the healer? Who is the mind reader? Will the Dragon eat them all?',
guildOnly: true
});
this.playing = new Set();
}
async run(msg) { // eslint-disable-line complexity
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
this.playing.add(msg.channel.id);
try {
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
const awaitedPlayers = await awaitPlayers(msg, 10, 3);
if (!awaitedPlayers) {
this.playing.delete(msg.channel.id);
return msg.say('Game could not be started...');
}
const players = await this.generatePlayers(awaitedPlayers);
let turn = 1;
while (players.size > 2 && players.some(p => p.role === 'dragon')) {
let eaten = null;
let healed = null;
await msg.say(`Night ${turn}, sending DMs...`);
for (const player of players.values()) {
if (player.role.includes('pleb')) continue;
await msg.say(`The ${player.role} is making their decision...`);
const valid = players.filterArray(p => p.role !== player.role);
await player.user.send(stripIndents`
${questions[player.role]} Please type the number.
${valid.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')}
`);
const filter = res => valid[Number.parseInt(res.content, 10) - 1];
const decision = await player.user.dmChannel.awaitMessages(filter, {
max: 1,
time: 120000
});
if (!decision.size) {
await player.user.send('Sorry, time is up!');
continue;
}
const choice = Number.parseInt(decision.first().content, 10);
if (player.role === 'dragon') {
const chosen = players.get(choice);
eaten = chosen.id;
await player.user.send(`${chosen.user.tag} will be eaten...`);
} else if (player.role === 'healer') {
const chosen = players.get(choice);
healed = chosen.id;
await player.user.send(`${chosen.user.tag} will be healed...`);
} else if (player.role === 'mind reader') {
await player.user.send(players.find(p => p.role === 'dragon').id === choice ? 'Yes.' : 'No.');
}
}
const display = eaten ? players.get(eaten).user : null;
const story = stories[Math.floor(Math.random() * stories.length)];
if (eaten && eaten !== healed) players.delete(eaten);
if (eaten && eaten === healed) {
await msg.say(stripIndents`
Late last night, a dragon emerged and tried to eat ${display}${story}
Thankfully, a healer stepped in just in time to save the day.
Who is this mysterious dragon? You have one minute to decide.
`);
} else if (eaten && players.size < 3) {
await msg.say(stripIndents`
Late last night, a dragon emerged and devoured poor ${display}${story}
Sadly, after the event, the final wizard ran in fear, leaving the dragon to rule forever.
`);
break;
} else if (eaten && eaten !== healed) {
await msg.say(stripIndents`
Late last night, a dragon emerged and devoured poor ${display}${story}
Who is this mysterious dragon? You have one minute to decide.
`);
} else {
await msg.say(stripIndents`
Late last night, a dragon emerged. Thankfully, however, it didn't try to eat anyone.
Who is this mysterious dragon? You have one minute to decide.
`);
}
await wait(60000);
const playersArr = Array.from(players.values());
await msg.say(stripIndents`
Who do you think is the dragon? Please type the number.
${playersArr.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')}
`);
const voted = [];
const filter = res => {
if (!players.exists(p => p.user.id === res.author.id)) return false;
if (voted.includes(res.author.id)) return false;
if (!playersArr[Number.parseInt(res.content, 10) - 1]) return false;
voted.push(res.author.id);
return true;
};
const votes = await msg.channel.awaitMessages(filter, {
max: players.size,
time: 120000
});
if (!votes.size) {
await msg.say('No one will be expelled.');
continue;
}
const expelled = this.getExpelled(votes, players, playersArr);
await msg.say(`${expelled.user} will be expelled.`);
players.delete(expelled.id);
++turn;
}
this.playing.delete(msg.channel.id);
const dragon = players.find(p => p.role === 'dragon');
if (!dragon) return msg.say('The dragon has been vanquished! Thanks for playing!');
return msg.say(`Oh no, the dragon wasn't caught in time... Nice job, ${dragon.user}!`);
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async generatePlayers(list) {
let roles = ['dragon', 'healer', 'mind reader'];
for (let i = 0; i < (list.length - 2); i++) roles.push(`pleb ${i + 1}`);
roles = shuffle(roles);
const players = new Collection();
let i = 0;
for (const user of list) {
players.set(user.id, {
id: user.id,
user,
role: roles[i]
});
await user.send(`Your role will be: ${roles[i]}!`);
i++;
}
}
getExpelled(votes, players, playersArr) {
const counts = new Collection();
for (const vote of votes.values()) {
const player = players.get(playersArr[Number.parseInt(vote.content, 10) - 1].id);
if (counts.has(player.id)) {
++counts.get(player.id).votes;
} else {
counts.set(player.id, {
id: player.id,
votes: 1,
user: player.user
});
}
}
return counts.sort((a, b) => b.votes - a.votes).first();
}
};
+42
View File
@@ -0,0 +1,42 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { CLEVERBOT_KEY } = process.env;
module.exports = class CleverbotCommand extends Command {
constructor(client) {
super(client, {
name: 'cleverbot',
aliases: ['clevs'],
group: 'other',
memberName: 'cleverbot',
description: 'Chat with Cleverbot.',
details: 'Only the bot owner(s) may use this command.',
ownerOnly: true,
args: [
{
key: 'message',
prompt: 'What do you want to say to Cleverbot?',
type: 'string'
}
]
});
this.convos = new Map();
}
async run(msg, { message }) {
try {
const { body } = await request
.get('https://www.cleverbot.com/getreply')
.query({
key: CLEVERBOT_KEY,
cs: this.convos.get(msg.channel.id),
input: message
});
this.convos.set(msg.channel.id, body.cs);
return msg.reply(body.output);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = class ScrabbleScoreCommand extends Command {
super(client, {
name: 'scrabble-score',
aliases: ['scrabble'],
group: 'number-edit',
group: 'search',
memberName: 'scrabble-score',
description: 'Responds with the scrabble score of a word.',
args: [
+37
View File
@@ -0,0 +1,37 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { WEBHOOK_ID, WEBHOOK_TOKEN } = process.env;
module.exports = class WebhookCommand extends Command {
constructor(client) {
super(client, {
name: 'webhook',
aliases: ['rin', 'rin-say'],
group: 'text-edit',
memberName: 'webhook',
description: 'Posts a message to the webhook defined in your `process.env`.',
details: 'Only the bot owner(s) may use this command.',
ownerOnly: true,
clientPermissions: ['MANAGE_MESSAGES'],
args: [
{
key: 'content',
prompt: 'What text would you like the webhook to say?',
type: 'string'
}
]
});
}
async run(msg, { content }) {
try {
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
await request
.post(`https://discordapp.com/api/webhooks/${WEBHOOK_ID}/${WEBHOOK_TOKEN}`)
.send({ content });
return null;
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "85.0.0",
"version": "85.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {