mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Pokemon cries
This commit is contained in:
@@ -65,5 +65,6 @@
|
||||
"To this day, no one has actually tried to date Dragon Fire after using the `dating` command. Several irl friends thought the joke was funny, though.",
|
||||
"The `screenshot` command uses a massive 2,000,000 entry array to check for adult sites. Some _still_ fall through the cracks.",
|
||||
"The `ship` command will call you a narcissist if you test yourself with yourself.",
|
||||
"Whenever Dragon Fire gets a real fortune cookie, he adds the fortune to the `fortune` command."
|
||||
"Whenever Dragon Fire gets a real fortune cookie, he adds the fortune to the `fortune` command.",
|
||||
"The `whos-that-pokemon` command will play a sound effect if both you and the bot are in a voice channel when the command is used.",
|
||||
]
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { Readable } = require('stream');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
const { silhouette } = require('../../util/Canvas');
|
||||
const path = require('path');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pokemon Solid.ttf'), { family: 'Pokemon' });
|
||||
@@ -68,11 +70,24 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
const names = data.names.map(name => name.name.toLowerCase());
|
||||
const attachment = await this.createImage(data, true);
|
||||
const answerAttachment = await this.createImage(data, false);
|
||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||
if (connection) {
|
||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'whos-that-pokemon.mp3'));
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
}
|
||||
await msg.reply('**You have 15 seconds, who\'s that Pokémon?**', { files: [attachment] });
|
||||
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||
max: 1,
|
||||
time: 15000
|
||||
});
|
||||
if (connection) {
|
||||
connection.dispatcher.end();
|
||||
await data.fetchCry();
|
||||
if (data.cry) {
|
||||
connection.play(Readable.from([data.cry]));
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
}
|
||||
}
|
||||
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [answerAttachment] });
|
||||
const guess = msgs.first().content.toLowerCase();
|
||||
const slug = this.client.pokemon.makeSlug(guess);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { Readable } = require('stream');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
|
||||
module.exports = class PokedexCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -69,6 +71,14 @@ module.exports = class PokedexCommand extends Command {
|
||||
if (found.id === data.id) return `**${found.name}**`;
|
||||
return found.name;
|
||||
}).join(' -> '));
|
||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||
if (connection) {
|
||||
await data.fetchCry();
|
||||
if (data.cry) {
|
||||
connection.play(Readable.from([data.cry]));
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
}
|
||||
}
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.34.8",
|
||||
"version": "119.34.9",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -37,6 +37,7 @@ module.exports = class Pokemon {
|
||||
};
|
||||
this.typesCached = data.missingno || false;
|
||||
this.missingno = data.missingno || false;
|
||||
this.cry = null;
|
||||
}
|
||||
|
||||
get displayID() {
|
||||
@@ -108,4 +109,15 @@ module.exports = class Pokemon {
|
||||
}
|
||||
return this.chain.data;
|
||||
}
|
||||
|
||||
async fetchCry() {
|
||||
if (this.cry) return this.cry;
|
||||
try {
|
||||
const { body } = await request.get(`https://pokemoncries.com/cries/${this.id}.mp3`);
|
||||
this.cry = body;
|
||||
return this.cry;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user