Refactor roleplay commands, bro-hoof, meme, remove face, add dotenv support

This commit is contained in:
Daniel Odendahl Jr
2018-08-28 22:26:58 +00:00
parent 5f81ce16c3
commit a4518c05ce
35 changed files with 349 additions and 287 deletions
+68
View File
@@ -0,0 +1,68 @@
# Discord-related info
XIAO_TOKEN=
# Seperate OWNERS with a ,
OWNERS=
XIAO_PREFIX=
INVITE=
# Emoji IDs
GOLD_FISH_EMOJI_ID=
MOCKING_EMOJI_ID=
SILVER_FISH_EMOJI_ID=
SUCCESS_EMOJI_ID=
# API Keys, IDs, and Secrets
ALPHA_VANTAGE_KEY=
CUSTOM_SEARCH_ID=
DEVIANTART_ID=
DEVIANTART_SECRET=
FLICKR_KEY=
GIPHY_KEY=
GITHUB_PASSWORD=
GITHUB_USERNAME=
GOOGLE_CALENDAR_ID=
GOOGLE_KEY=
GOV_KEY=
IMGUR_KEY=
OSU_KEY=
PERSONAL_GOOGLE_CALENDAR_ID=
RIOT_KEY=
STACKOVERFLOW_KEY=
TMDB_KEY=
TUMBLR_KEY=
TWITTER_KEY=
TWITTER_SECRET=
WATTPAD_KEY=
WEBHOOK_ID=
WEBHOOK_TOKEN=
WHATANIME_KEY=
WORDNIK_KEY=
XIAO_GITHUB_REPO_NAME=
XIAO_GITHUB_REPO_USERNAME=
YANDEX_KEY=
YODA_KEY=
# Imgur album IDs
BREAK_UP_ALBUM_ID=
BRO_HOOF_ALBUM_ID=
CUDDLE_ALBUM_ID=
EAT_ALBUM_ID=
EVOLVE_ALBUM_ID=
FALCON_PUNCH_ALBUM_ID=
FIDGET_ALBUM_ID=
FIST_BUMP_ALBUM_ID=
HIGH_FIVE_ALBUM_ID=
HIT_WITH_SHOVEL_ALBUM_ID=
HOLD_HANDS_ALBUM_ID=
HUG_ALBUM_ID=
INHALE_ALBUM_ID=
KILL_ALBUM_ID=
KISS_ALBUM_ID=
MARRY_ALBUM_ID=
PAT_ALBUM_ID=
POKE_ALBUM_ID=
POSTER_ALBUM_ID=
PUNCH_ALBUM_ID=
SLAP_ALBUM_ID=
TACKLE_ALBUM_ID=
XIAO_ALBUM_ID=
+3 -3
View File
@@ -63,12 +63,12 @@ on the [home server](https://discord.gg/sbMe32W).
* **joke**: Responds with a random joke. * **joke**: Responds with a random joke.
* **kiss-marry-kill**: Determines who to kiss, who to marry, and who to kill. * **kiss-marry-kill**: Determines who to kiss, who to marry, and who to kill.
* **magic-conch**: Asks your question to the Magic Conch. * **magic-conch**: Asks your question to the Magic Conch.
* **meme**: Responds with a random meme.
* **name**: Responds with a random name, with the gender of your choice. * **name**: Responds with a random name, with the gender of your choice.
* **number-fact**: Responds with a random fact about a specific number. * **number-fact**: Responds with a random fact about a specific number.
* **offspring**: Determines if your new child will be a boy or a girl. * **offspring**: Determines if your new child will be a boy or a girl.
* **opinion**: Determines the opinion on something. * **opinion**: Determines the opinion on something.
* **oracle-turret**: Responds with a random Oracle Turret quote. * **oracle-turret**: Responds with a random Oracle Turret quote.
* **pikachu**: Responds with a random image of Pikachu.
* **quantum-coin**: Flips a coin that lands on some form of nothing. * **quantum-coin**: Flips a coin that lands on some form of nothing.
* **quote**: Responds with a random quote. * **quote**: Responds with a random quote.
* **rate**: Rates something. * **rate**: Rates something.
@@ -174,7 +174,6 @@ on the [home server](https://discord.gg/sbMe32W).
* **coolness**: Determines a user's coolness. * **coolness**: Determines a user's coolness.
* **dick**: Determines your dick size. * **dick**: Determines your dick size.
* **face-analyze**: Determines the age, gender, and race of a face.
* **gender-analyze**: Determines the gender of a name. * **gender-analyze**: Determines the gender of a name.
* **guess-looks**: Guesses what a user looks like. * **guess-looks**: Guesses what a user looks like.
* **psycho-pass**: Determines your Crime Coefficient. * **psycho-pass**: Determines your Crime Coefficient.
@@ -226,6 +225,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **be-like-bill**: Sends a "Be Like Bill" meme with the name of your choice. * **be-like-bill**: Sends a "Be Like Bill" meme with the name of your choice.
* **color**: Sends an image of the color you choose. * **color**: Sends an image of the color you choose.
* **contrast**: Draws an image or a user's avatar but with contrast. * **contrast**: Draws an image or a user's avatar but with contrast.
* **create-meme**: Sends a meme with the text and background of your choice.
* **create-qr-code**: Converts text to a QR Code. * **create-qr-code**: Converts text to a QR Code.
* **demotivational-poster**: Draws an image or a user's avatar and the text you specify as a demotivational poster. * **demotivational-poster**: Draws an image or a user's avatar and the text you specify as a demotivational poster.
* **distort**: Draws an image or a user's avatar but distorted. * **distort**: Draws an image or a user's avatar but distorted.
@@ -235,7 +235,6 @@ on the [home server](https://discord.gg/sbMe32W).
* **ifunny**: Draws an image with the iFunny logo. * **ifunny**: Draws an image with the iFunny logo.
* **illegal**: Makes President Trump make your text illegal. * **illegal**: Makes President Trump make your text illegal.
* **invert**: Draws an image or a user's avatar but inverted. * **invert**: Draws an image or a user's avatar but inverted.
* **meme**: Sends a meme with the text and background of your choice.
* **minecraft-skin**: Sends the Minecraft skin for a user. * **minecraft-skin**: Sends the Minecraft skin for a user.
* **needs-more-jpeg**: Draws an image or a user's avatar as a low quality JPEG. * **needs-more-jpeg**: Draws an image or a user's avatar as a low quality JPEG.
* **osu-signature**: Creates a card based on an osu! user's stats. * **osu-signature**: Creates a card based on an osu! user's stats.
@@ -338,6 +337,7 @@ on the [home server](https://discord.gg/sbMe32W).
### Roleplay: ### Roleplay:
* **break-up**: Breaks up with a user. * **break-up**: Breaks up with a user.
* **bro-hoof**: Gives a user a bro-hoof.
* **cuddle**: Cuddles a user. * **cuddle**: Cuddles a user.
* **eat**: Eats a user. * **eat**: Eats a user.
* **evolve**: Evolves a user. * **evolve**: Evolves a user.
+1
View File
@@ -1,3 +1,4 @@
require('dotenv').config();
const { XIAO_TOKEN, OWNERS, XIAO_PREFIX, INVITE } = process.env; const { XIAO_TOKEN, OWNERS, XIAO_PREFIX, INVITE } = process.env;
const path = require('path'); const path = require('path');
const { CommandoClient } = require('discord.js-commando'); const { CommandoClient } = require('discord.js-commando');
-43
View File
@@ -1,43 +0,0 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { KAIROS_KEY, KAIROS_ID } = process.env;
const races = ['asian', 'black', 'hispanic', 'other', 'white'];
module.exports = class FaceAnalyzeCommand extends Command {
constructor(client) {
super(client, {
name: 'face-analyze',
aliases: ['analyze-face', 'face'],
group: 'analyze',
memberName: 'face',
description: 'Determines the age, gender, and race of a face.',
args: [
{
key: 'face',
prompt: 'What face do you want to scan?',
type: 'image'
}
]
});
}
async run(msg, { face }) {
try {
const { body } = await request
.post('https://api.kairos.com/detect')
.set({
app_id: KAIROS_ID,
app_key: KAIROS_KEY
})
.send({ image: face });
if (!body.images) return msg.reply('There are no faces in this image.');
if (body.images[0].faces.length > 1) return msg.reply('Please provide only one face in the image.');
const data = body.images[0].faces[0].attributes;
const race = races.sort((a, b) => data[b] - data[a])[0];
const gender = data.gender.maleConfidence > data.gender.femaleConfidence ? 'man' : 'woman';
return msg.reply(`I think this is a photo of a ${data.age} year old ${race} ${gender}.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -50,7 +50,7 @@ module.exports = class WhatAnimeCommand extends Command {
.query({ token: WHATANIME_KEY }); .query({ token: WHATANIME_KEY });
return { status: body.quota > 0, refresh: body.quota_ttl }; return { status: body.quota > 0, refresh: body.quota_ttl };
} catch (err) { } catch (err) {
return { status: false, refresh: null }; return { status: false, refresh: Infinity };
} }
} }
@@ -1,12 +1,13 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const request = require('node-superfetch'); const request = require('node-superfetch');
module.exports = class MemeCommand extends Command { module.exports = class CreateMemeCommand extends Command {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'meme', name: 'create-meme',
aliases: ['meme-generator', 'meme-gen'],
group: 'image-edit', group: 'image-edit',
memberName: 'meme', memberName: 'create-meme',
description: 'Sends a meme with the text and background of your choice.', description: 'Sends a meme with the text and background of your choice.',
clientPermissions: ['ATTACH_FILES'], clientPermissions: ['ATTACH_FILES'],
args: [ args: [
+17 -2
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { randomFromImgurAlbum } = require('../../util/Util'); const request = require('node-superfetch');
const { IMGUR_KEY, FIDGET_ALBUM_ID } = process.env;
module.exports = class FidgetCommand extends Command { module.exports = class FidgetCommand extends Command {
constructor(client) { constructor(client) {
@@ -11,14 +12,28 @@ module.exports = class FidgetCommand extends Command {
description: 'Responds with a random image of Fidget.', description: 'Responds with a random image of Fidget.',
clientPermissions: ['ATTACH_FILES'] clientPermissions: ['ATTACH_FILES']
}); });
this.cache = null;
} }
async run(msg) { async run(msg) {
try { try {
const nimbat = await randomFromImgurAlbum('DuO1T'); const nimbat = await this.random();
if (!nimbat) return msg.reply('This album has no images...');
return msg.say({ files: [nimbat] }); return msg.say({ files: [nimbat] });
} catch (err) { } catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
} }
} }
async random() {
if (this.cache) return this.cache[Math.floor(Math.random() * this.cache.length)].link;
const { body } = await request
.get(`https://api.imgur.com/3/album/${FIDGET_ALBUM_ID}`)
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
if (!body.data.images.length) return null;
this.cache = body.data.images;
setTimeout(() => { this.cache = null; }, 3.6e+6);
return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
}
}; };
+38
View File
@@ -0,0 +1,38 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { IMGUR_KEY, POSTER_ALBUM_ID } = process.env;
module.exports = class MemeCommand extends Command {
constructor(client) {
super(client, {
name: 'meme',
group: 'random',
memberName: 'meme',
description: 'Responds with a random meme.',
clientPermissions: ['ATTACH_FILES']
});
this.cache = null;
}
async run(msg) {
try {
const meme = await this.random();
if (!meme) return msg.reply('This album has no images...');
return msg.say({ files: [meme] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async random() {
if (this.cache) return this.cache[Math.floor(Math.random() * this.cache.length)].link;
const { body } = await request
.get(`https://api.imgur.com/3/album/${POSTER_ALBUM_ID}`)
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
if (!body.data.images.length) return null;
this.cache = body.data.images;
setTimeout(() => { this.cache = null; }, 3.6e+6);
return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
}
};
-24
View File
@@ -1,24 +0,0 @@
const Command = require('../../structures/Command');
const { randomFromImgurAlbum } = require('../../util/Util');
module.exports = class PikachuCommand extends Command {
constructor(client) {
super(client, {
name: 'pikachu',
aliases: ['pika'],
group: 'random',
memberName: 'pikachu',
description: 'Responds with a random image of Pikachu.',
clientPermissions: ['ATTACH_FILES']
});
}
async run(msg) {
try {
const pikachu = await randomFromImgurAlbum('qtk2J');
return msg.say({ files: [pikachu] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+17 -2
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { randomFromImgurAlbum } = require('../../util/Util'); const request = require('node-superfetch');
const { IMGUR_KEY, XIAO_ALBUM_ID } = process.env;
module.exports = class XiaoCommand extends Command { module.exports = class XiaoCommand extends Command {
constructor(client) { constructor(client) {
@@ -11,14 +12,28 @@ module.exports = class XiaoCommand extends Command {
description: 'Responds with a random image of Xiao Pai.', description: 'Responds with a random image of Xiao Pai.',
clientPermissions: ['ATTACH_FILES'] clientPermissions: ['ATTACH_FILES']
}); });
this.cache = null;
} }
async run(msg) { async run(msg) {
try { try {
const xiao = await randomFromImgurAlbum('S4e3r'); const xiao = await this.random();
if (!xiao) return msg.reply('This album has no images...');
return msg.say({ files: [xiao] }); return msg.say({ files: [xiao] });
} catch (err) { } catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
} }
} }
async random() {
if (this.cache) return this.cache[Math.floor(Math.random() * this.cache.length)].link;
const { body } = await request
.get(`https://api.imgur.com/3/album/${XIAO_ALBUM_ID}`)
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
if (!body.data.images.length) return null;
this.cache = body.data.images;
setTimeout(() => { this.cache = null; }, 3.6e+6);
return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
}
}; };
+7 -10
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { BREAK_UP_ALBUM_ID } = process.env;
module.exports = class BreakUpCommand extends Command { module.exports = class BreakUpCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'break-up', name: 'break-up',
@@ -9,6 +9,8 @@ module.exports = class BreakUpCommand extends Command {
group: 'roleplay', group: 'roleplay',
memberName: 'break-up', memberName: 'break-up',
description: 'Breaks up with a user.', description: 'Breaks up with a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: BREAK_UP_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -19,12 +21,7 @@ module.exports = class BreakUpCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** breaks up with **${user.username}**._`;
const gif = await randomFromImgurAlbum('QFWUb');
return msg.say(`_**${msg.author.username}** breaks up with **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+26
View File
@@ -0,0 +1,26 @@
const RoleplayCommand = require('../../structures/commands/Roleplay');
const { BRO_HOOF_ALBUM_ID } = process.env;
module.exports = class BroHoofCommand extends RoleplayCommand {
constructor(client) {
super(client, {
name: 'bro-hoof',
group: 'roleplay',
memberName: 'bro-hoof',
description: 'Gives a user a bro-hoof.',
clientPermissions: ['ATTACH_FILES'],
albumID: BRO_HOOF_ALBUM_ID,
args: [
{
key: 'user',
prompt: 'What user do you want to roleplay with?',
type: 'user'
}
]
});
}
generateText(msg, user) {
return `_**${msg.author.username}** gives **${user.username}** a bro-hoof._`;
}
};
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { CUDDLE_ALBUM_ID } = process.env;
module.exports = class CuddleCommand extends Command { module.exports = class CuddleCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'cuddle', name: 'cuddle',
group: 'roleplay', group: 'roleplay',
memberName: 'cuddle', memberName: 'cuddle',
description: 'Cuddles a user.', description: 'Cuddles a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: CUDDLE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class CuddleCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** cuddles with **${user.username}**._`;
const gif = await randomFromImgurAlbum('sVjXp');
return msg.say(`_**${msg.author.username}** cuddles with **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { EAT_ALBUM_ID } = process.env;
module.exports = class EatCommand extends Command { module.exports = class EatCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'eat', name: 'eat',
group: 'roleplay', group: 'roleplay',
memberName: 'eat', memberName: 'eat',
description: 'Eats a user.', description: 'Eats a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: EAT_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class EatCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** eats **${user.username}**._`;
const gif = await randomFromImgurAlbum('GP2zD');
return msg.say(`_**${msg.author.username}** eats **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { EVOLVE_ALBUM_ID } = process.env;
module.exports = class EvolveCommand extends Command { module.exports = class EvolveCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'evolve', name: 'evolve',
group: 'roleplay', group: 'roleplay',
memberName: 'evolve', memberName: 'evolve',
description: 'Evolves a user.', description: 'Evolves a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: EVOLVE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class EvolveCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${user.username}** is evolving!_`;
const gif = await randomFromImgurAlbum('QaDeO');
return msg.say(`_**${user.username}** is evolving!_`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { FALCON_PUNCH_ALBUM_ID } = process.env;
module.exports = class FalconPunchCommand extends Command { module.exports = class FalconPunchCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'falcon-punch', name: 'falcon-punch',
group: 'roleplay', group: 'roleplay',
memberName: 'falcon-punch', memberName: 'falcon-punch',
description: 'Falcon Punches a user.', description: 'Falcon Punches a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: FALCON_PUNCH_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class FalconPunchCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** falcon punches **${user.username}**._`;
const gif = await randomFromImgurAlbum('mJauN');
return msg.say(`_**${msg.author.username}** falcon punches **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+8 -11
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { FIST_BUMP_ALBUM_ID } = process.env;
module.exports = class FistBumpCommand extends Command { module.exports = class FistBumpCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'fist-bump', name: 'fist-bump',
group: 'roleplay', group: 'roleplay',
memberName: 'fist-bump', memberName: 'fist-bump',
description: 'Fistbumps a user.', description: 'Fist-bumps a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: FIST_BUMP_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class FistBumpCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** fist-bumps **${user.username}**._`;
const gif = await randomFromImgurAlbum('9D3WE');
return msg.say(`_**${msg.author.username}** fist-bumps **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { HIGH_FIVE_ALBUM_ID } = process.env;
module.exports = class HighFiveCommand extends Command { module.exports = class HighFiveCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'high-five', name: 'high-five',
group: 'roleplay', group: 'roleplay',
memberName: 'high-five', memberName: 'high-five',
description: 'High Fives a user.', description: 'High Fives a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: HIGH_FIVE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class HighFiveCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** high-fives **${user.username}**._`;
const gif = await randomFromImgurAlbum('1Dotc');
return msg.say(`_**${msg.author.username}** high-fives **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { HIT_WITH_SHOVEL_ALBUM_ID } = process.env;
module.exports = class HitWithShovelCommand extends Command { module.exports = class HitWithShovelCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'hit-with-shovel', name: 'hit-with-shovel',
group: 'roleplay', group: 'roleplay',
memberName: 'hit-with-shovel', memberName: 'hit-with-shovel',
description: 'Hits a user with a shovel.', description: 'Hits a user with a shovel.',
clientPermissions: ['ATTACH_FILES'],
albumID: HIT_WITH_SHOVEL_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class HitWithShovelCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** hits **${user.username}** with a shovel._`;
const gif = await randomFromImgurAlbum('IA35f');
return msg.say(`_**${msg.author.username}** hits **${user.username}** with a shovel._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { HOLD_HANDS_ALBUM_ID } = process.env;
module.exports = class HoldHandsCommand extends Command { module.exports = class HoldHandsCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'hold-hands', name: 'hold-hands',
@@ -9,6 +9,8 @@ module.exports = class HoldHandsCommand extends Command {
group: 'roleplay', group: 'roleplay',
memberName: 'hold-hands', memberName: 'hold-hands',
description: 'Holds hands with a user.', description: 'Holds hands with a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: HOLD_HANDS_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -19,12 +21,7 @@ module.exports = class HoldHandsCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** holds **${user.username}**'s hand._`;
const gif = await randomFromImgurAlbum('K67Lp');
return msg.say(`_**${msg.author.username}** holds **${user.username}**'s hand._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { HUG_ALBUM_ID } = process.env;
module.exports = class HugCommand extends Command { module.exports = class HugCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'hug', name: 'hug',
group: 'roleplay', group: 'roleplay',
memberName: 'hug', memberName: 'hug',
description: 'Hugs a user.', description: 'Hugs a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: HUG_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class HugCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** hugs **${user.username}**._`;
const gif = await randomFromImgurAlbum('v4Sdd');
return msg.say(`_**${msg.author.username}** hugs **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -13
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { INHALE_ALBUM_ID } = process.env;
module.exports = class InhaleCommand extends Command { module.exports = class InhaleCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'inhale', name: 'inhale',
group: 'roleplay', group: 'roleplay',
memberName: 'inhale', memberName: 'inhale',
description: 'Inhales a user.', description: 'Inhales a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: INHALE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,15 +20,7 @@ module.exports = class InhaleCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** inhales **${user.username}** but gained no ability..._`;
const gif = await randomFromImgurAlbum('QKFM6');
return msg.say(
`_**${msg.author.username}** inhales **${user.username}** but gained no ability..._`,
{ files: [gif] }
);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { KILL_ALBUM_ID } = process.env;
module.exports = class KillCommand extends Command { module.exports = class KillCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'kill', name: 'kill',
group: 'roleplay', group: 'roleplay',
memberName: 'kill', memberName: 'kill',
description: 'Kills a user.', description: 'Kills a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: KILL_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class KillCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** kills **${user.username}**._`;
const gif = await randomFromImgurAlbum('YhwEI');
return msg.say(`_**${msg.author.username}** kills **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { KISS_ALBUM_ID } = process.env;
module.exports = class KissCommand extends Command { module.exports = class KissCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'kiss', name: 'kiss',
group: 'roleplay', group: 'roleplay',
memberName: 'kiss', memberName: 'kiss',
description: 'Kisses a user.', description: 'Kisses a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: KISS_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class KissCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** kisses **${user.username}**._`;
const gif = await randomFromImgurAlbum('twIbD');
return msg.say(`_**${msg.author.username}** kisses **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { MARRY_ALBUM_ID } = process.env;
module.exports = class MarryCommand extends Command { module.exports = class MarryCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'marry', name: 'marry',
group: 'roleplay', group: 'roleplay',
memberName: 'marry', memberName: 'marry',
description: 'Marries a user.', description: 'Marries a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: MARRY_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class MarryCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** marries **${user.username}**._`;
const gif = await randomFromImgurAlbum('4H0EP');
return msg.say(`_**${msg.author.username}** marries **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { PAT_ALBUM_ID } = process.env;
module.exports = class PatCommand extends Command { module.exports = class PatCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'pat', name: 'pat',
group: 'roleplay', group: 'roleplay',
memberName: 'pat', memberName: 'pat',
description: 'Pats a user.', description: 'Pats a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: PAT_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class PatCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** pats **${user.username}**._`;
const gif = await randomFromImgurAlbum('JPwZG');
return msg.say(`_**${msg.author.username}** pats **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { POKE_ALBUM_ID } = process.env;
module.exports = class PokeCommand extends Command { module.exports = class PokeCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'poke', name: 'poke',
group: 'roleplay', group: 'roleplay',
memberName: 'poke', memberName: 'poke',
description: 'Pokes a user.', description: 'Pokes a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: POKE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class PokeCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** pokes **${user.username}**._`;
const gif = await randomFromImgurAlbum('ek91V');
return msg.say(`_**${msg.author.username}** pokes **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { PUNCH_ALBUM_ID } = process.env;
module.exports = class PunchCommand extends Command { module.exports = class PunchCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'punch', name: 'punch',
group: 'roleplay', group: 'roleplay',
memberName: 'punch', memberName: 'punch',
description: 'Punches a user.', description: 'Punches a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: PUNCH_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class PunchCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** punches **${user.username}**._`;
const gif = await randomFromImgurAlbum('mZrp8');
return msg.say(`_**${msg.author.username}** punches **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,13 +1,15 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { PUNCH_ALBUM_ID } = process.env;
module.exports = class SlapCommand extends Command { module.exports = class SlapCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'slap', name: 'slap',
group: 'roleplay', group: 'roleplay',
memberName: 'slap', memberName: 'slap',
description: 'Slaps a user.', description: 'Slaps a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: PUNCH_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -18,12 +20,7 @@ module.exports = class SlapCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** slaps **${user.username}**._`;
const gif = await randomFromImgurAlbum('6wu9G');
return msg.say(`_**${msg.author.username}** slaps **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
+7 -10
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command'); const RoleplayCommand = require('../../structures/commands/Roleplay');
const { randomFromImgurAlbum } = require('../../util/Util'); const { TACKLE_ALBUM_ID } = process.env;
module.exports = class TackleCommand extends Command { module.exports = class TackleCommand extends RoleplayCommand {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'tackle', name: 'tackle',
@@ -9,6 +9,8 @@ module.exports = class TackleCommand extends Command {
group: 'roleplay', group: 'roleplay',
memberName: 'tackle', memberName: 'tackle',
description: 'Tackles a user.', description: 'Tackles a user.',
clientPermissions: ['ATTACH_FILES'],
albumID: TACKLE_ALBUM_ID,
args: [ args: [
{ {
key: 'user', key: 'user',
@@ -19,12 +21,7 @@ module.exports = class TackleCommand extends Command {
}); });
} }
async run(msg, { user }) { generateText(msg, user) {
try { return `_**${msg.author.username}** tackles **${user.username}**._`;
const gif = await randomFromImgurAlbum('SZGLX');
return msg.say(`_**${msg.author.username}** tackles **${user.username}**._`, { files: [gif] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
} }
}; };
@@ -70,7 +70,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
.get('https://na1.api.riotgames.com/lol/static-data/v3/versions') .get('https://na1.api.riotgames.com/lol/static-data/v3/versions')
.query({ api_key: RIOT_KEY }); .query({ api_key: RIOT_KEY });
[this.version] = body; [this.version] = body;
setTimeout(() => { this.version = null; }, 3600000); setTimeout(() => { this.version = null; }, 3.6e+6);
return body; return body;
} }
+1 -1
View File
@@ -12,6 +12,6 @@ module.exports = class EatPantCommand extends Command {
} }
run(msg) { run(msg) {
return msg.say({ files: ['https://i.imgur.com/sSmhvxt.jpg'] }); return msg.say({ files: ['https://i.imgur.com/uEk0kI4.jpg'] });
} }
}; };
+2 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "87.5.1", "version": "88.0.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
@@ -39,6 +39,7 @@
"custom-translate": "^2.2.6", "custom-translate": "^2.2.6",
"discord.js": "github:discordjs/discord.js", "discord.js": "github:discordjs/discord.js",
"discord.js-commando": "github:discordjs/Commando", "discord.js-commando": "github:discordjs/Commando",
"dotenv": "^6.0.0",
"erlpack": "github:discordapp/erlpack", "erlpack": "github:discordapp/erlpack",
"mathjs": "^5.1.1", "mathjs": "^5.1.1",
"neopet-image-finder": "^4.0.0", "neopet-image-finder": "^4.0.0",
+33
View File
@@ -0,0 +1,33 @@
const request = require('node-superfetch');
const Command = require('../Command');
const { IMGUR_KEY } = process.env;
module.exports = class RoleplayCommand extends Command {
constructor(client, info) {
super(client, info);
this.albumID = info.albumID;
this.cache = null;
}
async run(msg, { user }) {
try {
const image = await this.random();
if (!image) return msg.reply('This album has no images...');
return msg.say(this.generateText(msg, user), { files: [image] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async random() {
if (this.cache) return this.cache[Math.floor(Math.random() * this.cache.length)].link;
const { body } = await request
.get(`https://api.imgur.com/3/album/${this.albumID}`)
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
if (!body.data.images.length) return null;
this.cache = body.data.images;
setTimeout(() => { this.cache = null; }, 3.6e+6);
return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
}
};
+3 -12
View File
@@ -1,8 +1,7 @@
const request = require('node-superfetch');
const crypto = require('crypto'); const crypto = require('crypto');
const { IMGUR_KEY, SUCCESS_EMOJI_ID } = process.env; const { SUCCESS_EMOJI_ID } = process.env;
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea']; const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea', 'ya'];
const no = ['no', 'n', 'nah', 'nope']; const no = ['no', 'n', 'nah', 'nope', 'nop'];
module.exports = class Util { module.exports = class Util {
static delay(ms) { static delay(ms) {
@@ -59,14 +58,6 @@ module.exports = class Util {
return crypto.createHash(algorithm).update(text).digest('hex'); return crypto.createHash(algorithm).update(text).digest('hex');
} }
static async randomFromImgurAlbum(album) {
const { body } = await request
.get(`https://api.imgur.com/3/album/${album}`)
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
if (!body.data.images.length) return null;
return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
}
static today(timeZone) { static today(timeZone) {
const now = new Date(); const now = new Date();
if (timeZone) now.setUTCHours(now.getUTCHours() + timeZone); if (timeZone) now.setUTCHours(now.getUTCHours() + timeZone);