Pokemon cries

This commit is contained in:
Dragon Fire
2020-10-30 12:30:34 -04:00
parent a11d9f02c3
commit 5daacf8f16
6 changed files with 40 additions and 2 deletions
+2 -1
View File
@@ -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.
+15
View File
@@ -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);
+10
View File
@@ -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
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.34.8",
"version": "119.34.9",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+12
View File
@@ -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;
}
}
};