mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
62.0.0
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,49 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { createCanvas, registerFont } = require('canvas');
|
||||||
|
const path = require('path');
|
||||||
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Captcha.ttf'), { family: 'Captcha' });
|
||||||
|
|
||||||
|
module.exports = class CaptchaQuizCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'captcha-quiz',
|
||||||
|
aliases: ['captcha'],
|
||||||
|
group: 'games',
|
||||||
|
memberName: 'captcha-quiz',
|
||||||
|
description: 'Try to guess what the captcha says.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg) {
|
||||||
|
const canvas = createCanvas(100, 32);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const text = this.randomText(5);
|
||||||
|
ctx.fillStyle = 'white';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.strokeStyle = '#0088cc';
|
||||||
|
ctx.font = '26px Captcha';
|
||||||
|
ctx.rotate(-0.05);
|
||||||
|
ctx.strokeText(text, 15, 26);
|
||||||
|
await msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'captcha-quiz.png' }] });
|
||||||
|
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||||
|
max: 1,
|
||||||
|
time: 15000
|
||||||
|
});
|
||||||
|
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${text}.`);
|
||||||
|
if (msgs.first().content !== text) return msg.say(`Nope, sorry, it's ${text}.`);
|
||||||
|
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||||
|
}
|
||||||
|
|
||||||
|
randomText(len) {
|
||||||
|
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789'.split('');
|
||||||
|
const result = [];
|
||||||
|
for (let i = 0; i > len; i++) result.push(pool[Math.floor(Math.random() * pool.length)]);
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,13 +11,13 @@ const maxValues = {
|
|||||||
impossible: 1000000
|
impossible: 1000000
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = class MathGameCommand extends Command {
|
module.exports = class MathQuizCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'math-game',
|
name: 'math-quiz',
|
||||||
aliases: ['math-quiz', 'math-test'],
|
aliases: ['math-game'],
|
||||||
group: 'games',
|
group: 'games',
|
||||||
memberName: 'math',
|
memberName: 'math-quiz',
|
||||||
description: 'See how fast you can answer a math problem in a given time limit.',
|
description: 'See how fast you can answer a math problem in a given time limit.',
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -9,7 +9,7 @@ module.exports = class QuizCommand extends Command {
|
|||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'quiz',
|
name: 'quiz',
|
||||||
aliases: ['jeopardy', 'test'],
|
aliases: ['jeopardy'],
|
||||||
group: 'games',
|
group: 'games',
|
||||||
memberName: 'quiz',
|
memberName: 'quiz',
|
||||||
description: 'Answer a quiz question.',
|
description: 'Answer a quiz question.',
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ const times = {
|
|||||||
impossible: 5000
|
impossible: 5000
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = class TypingGameCommand extends Command {
|
module.exports = class TypingTestCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'typing-game',
|
name: 'typing-test',
|
||||||
aliases: ['typing-quiz', 'typing-test'],
|
aliases: ['typing-game'],
|
||||||
group: 'games',
|
group: 'games',
|
||||||
memberName: 'typing',
|
memberName: 'typing-test',
|
||||||
description: 'See how fast you can type a sentence in a given time limit.',
|
description: 'See how fast you can type a sentence in a given time limit.',
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@@ -106,24 +106,11 @@ module.exports = class WizardConventionCommand extends Command {
|
|||||||
max: players.size,
|
max: players.size,
|
||||||
time: 120000
|
time: 120000
|
||||||
});
|
});
|
||||||
const counts = new Collection();
|
if (!votes.size) {
|
||||||
for (const vote of votes.values()) {
|
|
||||||
const player = players.get(playersArr[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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!counts.size) {
|
|
||||||
await msg.say('No one will be expelled.');
|
await msg.say('No one will be expelled.');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const expelled = counts.sort((a, b) => b.votes - a.votes).first();
|
const expelled = this.getExpelled(votes, players, playersArr);
|
||||||
await msg.say(`${expelled.user} will be expelled.`);
|
await msg.say(`${expelled.user} will be expelled.`);
|
||||||
players.delete(expelled.id);
|
players.delete(expelled.id);
|
||||||
++turn;
|
++turn;
|
||||||
@@ -154,4 +141,21 @@ module.exports = class WizardConventionCommand extends Command {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getExpelled(votes, players, playersArr) {
|
||||||
|
const counts = new Collection();
|
||||||
|
for (const vote of votes.values()) {
|
||||||
|
const player = players.get(playersArr[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();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module.exports = class InfoCommand extends Command {
|
|||||||
run(msg) {
|
run(msg) {
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0x00AE86)
|
.setColor(0x00AE86)
|
||||||
.setFooter('©2017 dragonfire535#8081')
|
.setFooter('©2017 dragonfire535#0817')
|
||||||
.addField('❯ Servers',
|
.addField('❯ Servers',
|
||||||
this.client.guilds.size, true)
|
this.client.guilds.size, true)
|
||||||
.addField('❯ Shards',
|
.addField('❯ Shards',
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "61.5.0",
|
"version": "62.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