mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Word Spud Command
This commit is contained in:
@@ -136,7 +136,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 422
|
||||
Total: 423
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -415,6 +415,7 @@ Total: 422
|
||||
* **russian-roulette:** Who will pull the trigger and die first?
|
||||
* **tic-tac-toe:** Play a game of tic-tac-toe with another user.
|
||||
* **word-chain:** Try to come up with words that start with the last letter of your opponent's word.
|
||||
* **word-spud:** Hot potato, but with words.
|
||||
|
||||
### Image Manipulation:
|
||||
|
||||
@@ -911,6 +912,7 @@ here.
|
||||
- [Jackbox Games](https://www.jackboxgames.com/)
|
||||
* guesspionage ([Original "Guesspionage" Game](https://www.jackboxgames.com/guesspionage/))
|
||||
* lie-swatter ([Original "Lie Swatter" Game](https://www.jackboxgames.com/lie-swatter/))
|
||||
* word-spud ([Original "Word Spud" Game](https://www.jackboxgames.com/word-spud/))
|
||||
- [jasmaa](https://github.com/jasmaa/)
|
||||
* neko-atsume-password ([API URL](https://github.com/jasmaa/nekoatsume-password-learner/blob/master/neko_pswd.py#L4))
|
||||
- [JellyNeo Item Database](https://items.jellyneo.net/)
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { verify } = require('../../util/Util');
|
||||
const startWords = require('../../assets/json/word-list');
|
||||
|
||||
module.exports = class WordSpudCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'word-spud',
|
||||
group: 'games-mp',
|
||||
memberName: 'word-spud',
|
||||
description: 'Hot potato, but with words.',
|
||||
guildOnly: true,
|
||||
credit: [
|
||||
{
|
||||
name: 'Jackbox Games',
|
||||
url: 'https://www.jackboxgames.com/',
|
||||
reason: 'Original "Word Spud" Game',
|
||||
reasonURL: 'https://www.jackboxgames.com/word-spud/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'opponent',
|
||||
prompt: 'What user would you like to play against?',
|
||||
type: 'user'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { opponent }) {
|
||||
if (opponent.bot) return msg.reply('Bots may not be played against.');
|
||||
if (opponent.id === msg.author.id) return msg.reply('You may not play against yourself.');
|
||||
const current = this.client.games.get(msg.channel.id);
|
||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||
this.client.games.set(msg.channel.id, { name: this.name });
|
||||
try {
|
||||
await msg.say(`${opponent}, do you accept this challenge?`);
|
||||
const verification = await verify(msg.channel, opponent);
|
||||
if (!verification) {
|
||||
this.client.games.delete(msg.channel.id);
|
||||
return msg.say('Looks like they declined...');
|
||||
}
|
||||
let currentWord = startWords[Math.floor(Math.random() * startWords.length)];
|
||||
let lastTurnTimeout = false;
|
||||
let gameEnd = false;
|
||||
let userTurn = false;
|
||||
while (!gameEnd) {
|
||||
const player = userTurn ? msg.author : opponent;
|
||||
await msg.say(stripIndents`
|
||||
${player}, continue the chain: **${currentWord} ...?**
|
||||
_Type \`end\` to end the game._
|
||||
`);
|
||||
const filter = res => res.author.id === player.id && res.content.length > 100;
|
||||
const msgs = await msg.channel.awaitMessages(filter, {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
if (!msgs.size) {
|
||||
await msg.say('No ideas? No problem, moving on.');
|
||||
userTurn = !userTurn;
|
||||
if (lastTurnTimeout) {
|
||||
break;
|
||||
} else {
|
||||
lastTurnTimeout = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const word = msgs.first().content.toLowerCase();
|
||||
if (word === 'end') {
|
||||
gameEnd = true;
|
||||
break;
|
||||
}
|
||||
await msg.say(`${currentWord} **${word}**? Cool!`);
|
||||
userTurn = !userTurn;
|
||||
if (lastTurnTimeout) lastTurnTimeout = false;
|
||||
}
|
||||
this.client.games.delete(msg.channel.id);
|
||||
return msg.say('Thanks for playing!');
|
||||
} catch (err) {
|
||||
this.client.games.delete(msg.channel.id);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.13.2",
|
||||
"version": "114.14.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user