mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 14:55:40 +02:00
Spam War Command
This commit is contained in:
@@ -252,7 +252,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 531
|
||||
Total: 532
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -576,6 +576,7 @@ Total: 531
|
||||
* **poker:** Play poker with up to 5 other users.
|
||||
* **quiz-duel:** Answer a series of quiz questions against an opponent.
|
||||
* **russian-roulette:** Who will pull the trigger and die first?
|
||||
* **spam-war:** See who can type more characters the fastest.
|
||||
* **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.
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { delay, verify } = require('../../util/Util');
|
||||
|
||||
module.exports = class SpamWarCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'spam-war',
|
||||
aliases: ['spam-fight', 'spam-battle'],
|
||||
group: 'games-mp',
|
||||
memberName: 'spam-war',
|
||||
description: 'See who can type more characters the fastest.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'opponent',
|
||||
prompt: 'What user would you like to challenge?',
|
||||
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...');
|
||||
}
|
||||
await msg.say('You get one point per character in your messages. You get 1 minute to spam.');
|
||||
await delay(5000);
|
||||
await msg.say('You have **1 minute** to spam. Go!');
|
||||
const msgs = await msg.channel.awaitMessages(res => [opponent.id, msg.author.id].includes(res.author.id), {
|
||||
time: 60000
|
||||
});
|
||||
const authorMsgs = msgs
|
||||
.filter(authorMsg => authorMsg.author.id === msg.author.id)
|
||||
.reduce((a, b) => a + b.content.length, 0);
|
||||
const opponentMsgs = msgs
|
||||
.filter(opponentMsg => opponentMsg.author.id === opponent.id)
|
||||
.reduce((a, b) => a + b.content.length, 0);
|
||||
const winner = authorMsgs > opponentMsgs ? msg.author : opponent;
|
||||
const winnerPts = authorMsgs > opponentMsgs ? authorMsgs : opponentMsgs;
|
||||
const loserPts = authorMsgs > opponentMsgs ? opponentMsgs : authorMsgs;
|
||||
this.client.games.delete(msg.channel.id);
|
||||
if (authorMsgs === opponentMsgs) {
|
||||
return msg.say(`It was a tie! What are the odds? You both got **${winnerPts}** points!`);
|
||||
}
|
||||
return msg.say(`The winner is ${winner}, with **${winnerPts}** points! Your opponent only got ${loserPts}...`);
|
||||
} catch (err) {
|
||||
this.client.games.delete(msg.channel.id);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.12.5",
|
||||
"version": "119.13.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user