mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Remove some things (surprise)
This commit is contained in:
@@ -4,15 +4,12 @@
|
|||||||
[](https://www.patreon.com/dragonfire535)
|
[](https://www.patreon.com/dragonfire535)
|
||||||
[](https://www.paypal.me/dragonfire535)
|
[](https://www.paypal.me/dragonfire535)
|
||||||
|
|
||||||
> Note: The bot is no longer available for invite.
|
|
||||||
|
|
||||||
Xiao is a Discord bot coded in JavaScript with
|
Xiao is a Discord bot coded in JavaScript with
|
||||||
[discord.js](https://discord.js.org/) using the
|
[discord.js](https://discord.js.org/) using the
|
||||||
[Commando](https://github.com/discordjs/Commando) command framework. With over
|
[Commando](https://github.com/discordjs/Commando) command framework. With over
|
||||||
300 commands, she is one of the most feature-filled bots out there, and formerly
|
300 commands, she is one of the most feature-filled bots out there.
|
||||||
served over 10,000 servers with a uniquely devoted fanbase.
|
|
||||||
|
|
||||||
## Commands (311)
|
## Commands (307)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **prefix**: Shows or sets the command prefix.
|
* **prefix**: Shows or sets the command prefix.
|
||||||
@@ -192,11 +189,9 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
### Games:
|
### Games:
|
||||||
|
|
||||||
* **akinator**: Think about a real or fictional character, I will try to guess who it is.
|
* **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!
|
* **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.
|
* **battle**: Engage in a turn-based battle against another user or the AI.
|
||||||
* **captcha-quiz**: Try to guess what the captcha says.
|
* **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.
|
* **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?
|
* **emoji-emoji-revolution**: Can you type arrow emoji faster than anyone else has ever typed them before?
|
||||||
* **fishy**: Go fishing.
|
* **fishy**: Go fishing.
|
||||||
@@ -214,7 +209,6 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
* **tic-tac-toe**: Play a game of tic-tac-toe with another user.
|
* **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.
|
* **typing-test**: See how fast you can type a sentence in a given time limit.
|
||||||
* **whos-that-pokemon**: Guess who that Pokémon is.
|
* **whos-that-pokemon**: Guess who that Pokémon is.
|
||||||
* **wizard-convention**: Who is the Dragon? Who is the healer? Who is the mind reader? Will the Dragon eat them all?
|
|
||||||
|
|
||||||
### Voice Channel:
|
### Voice Channel:
|
||||||
|
|
||||||
@@ -355,7 +349,6 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
|
|
||||||
### Other:
|
### Other:
|
||||||
|
|
||||||
* **cleverbot**: Chat with Cleverbot.
|
|
||||||
* **prune**: Deletes up to 99 messages from the current channel.
|
* **prune**: Deletes up to 99 messages from the current channel.
|
||||||
* **strawpoll**: Generates a Strawpoll with the options you provide.
|
* **strawpoll**: Generates a Strawpoll with the options you provide.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { XIAO_TOKEN, OWNERS, XIAO_PREFIX, INVITE, XIAO_ALLOWED_GUILDS } = process.env;
|
const { XIAO_TOKEN, OWNERS, XIAO_PREFIX, INVITE } = process.env;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const XiaoClient = require('./structures/Client');
|
const XiaoClient = require('./structures/Client');
|
||||||
const client = new XiaoClient({
|
const client = new XiaoClient({
|
||||||
@@ -11,7 +11,6 @@ const client = new XiaoClient({
|
|||||||
});
|
});
|
||||||
const SequelizeProvider = require('./providers/Sequelize');
|
const SequelizeProvider = require('./providers/Sequelize');
|
||||||
const activities = require('./assets/json/activity');
|
const activities = require('./assets/json/activity');
|
||||||
const allowedGuilds = XIAO_ALLOWED_GUILDS ? XIAO_ALLOWED_GUILDS.split(',') : null;
|
|
||||||
|
|
||||||
client.registry
|
client.registry
|
||||||
.registerDefaultTypes()
|
.registerDefaultTypes()
|
||||||
@@ -57,17 +56,6 @@ client.on('ready', async () => {
|
|||||||
const activity = activities[Math.floor(Math.random() * activities.length)];
|
const activity = activities[Math.floor(Math.random() * activities.length)];
|
||||||
client.user.setActivity(activity.text, { type: activity.type });
|
client.user.setActivity(activity.text, { type: activity.type });
|
||||||
}, 60000);
|
}, 60000);
|
||||||
if (allowedGuilds) {
|
|
||||||
for (const guild of client.guilds.values()) {
|
|
||||||
if (allowedGuilds.includes(guild.id)) continue;
|
|
||||||
try {
|
|
||||||
await guild.leave();
|
|
||||||
console.log(`[GUILD] Left non-allowed guild ${guild.name}. (${guild.id})`);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`[GUILD] Failed to leave non-allowed guild ${guild.name}. (${guild.id})`, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('disconnect', event => {
|
client.on('disconnect', event => {
|
||||||
@@ -75,17 +63,6 @@ client.on('disconnect', event => {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildCreate', async guild => {
|
|
||||||
if (!allowedGuilds) return;
|
|
||||||
if (allowedGuilds.includes(guild.id)) return;
|
|
||||||
try {
|
|
||||||
await guild.leave();
|
|
||||||
console.log(`[GUILD] Left non-allowed guild ${guild.name}. (${guild.id})`);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`[GUILD] Failed to leave non-allowed guild ${guild.name}. (${guild.id})`, err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('commandRun', command => console.log(`[COMMAND] Ran command ${command.groupID}:${command.memberName}.`));
|
client.on('commandRun', command => console.log(`[COMMAND] Ran command ${command.groupID}:${command.memberName}.`));
|
||||||
|
|
||||||
client.on('error', err => console.error('[ERROR]', err));
|
client.on('error', err => console.error('[ERROR]', err));
|
||||||
|
|||||||
@@ -15,10 +15,6 @@
|
|||||||
"text": "anime",
|
"text": "anime",
|
||||||
"type": "WATCHING"
|
"type": "WATCHING"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"text": "Dust: An Elysian Tail",
|
|
||||||
"type": "PLAYING"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"text": "over the inn",
|
"text": "over the inn",
|
||||||
"type": "WATCHING"
|
"type": "WATCHING"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"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."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
|
||||||
const snekfetch = require('snekfetch');
|
|
||||||
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 snekfetch
|
|
||||||
.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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "73.2.10",
|
"version": "74.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user