diff --git a/assets/json/fidget.json b/assets/json/fidget.json deleted file mode 100644 index a9e567d0..00000000 --- a/assets/json/fidget.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - "https://i.imgur.com/O1PpKIM.png", - "https://i.imgur.com/UUDnevJ.jpg", - "https://i.imgur.com/8qTYRd7.png", - "https://i.imgur.com/g9QZRl3.jpg", - "https://i.imgur.com/OQMpY8c.jpg", - "https://i.imgur.com/e7rEjLA.jpg", - "https://i.imgur.com/2JrLfHP.png", - "https://i.imgur.com/q95iQIA.jpg", - "https://i.imgur.com/8oyH1nv.jpg", - "https://i.imgur.com/tDljuxk.png", - "https://i.imgur.com/s56bWfY.jpg", - "https://i.imgur.com/ycX6iOI.png", - "https://i.imgur.com/RixbWXs.jpg", - "https://i.imgur.com/J8V9v4Q.jpg", - "https://i.imgur.com/uDVtLns.jpg", - "https://i.imgur.com/cPKI2Kq.jpg", - "https://i.imgur.com/2FgIVhO.png", - "https://i.imgur.com/Vxz0BFU.jpg", - "https://i.imgur.com/jt4R4mK.png", - "https://i.imgur.com/zRhXdhd.png", - "https://i.imgur.com/l45arMd.jpg", - "https://i.imgur.com/hjE5rLf.jpg", - "https://i.imgur.com/fFrdYmO.png", - "https://i.imgur.com/W8jerBP.jpg", - "https://i.imgur.com/h2OH8iO.jpg" -] diff --git a/assets/json/pikachu.json b/assets/json/pikachu.json deleted file mode 100644 index 49ca6fa8..00000000 --- a/assets/json/pikachu.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - "https://i.imgur.com/7yQdFC2.jpg", - "https://i.imgur.com/76S8DP5.jpg", - "https://i.imgur.com/2OmeiAr.jpg", - "https://i.imgur.com/kHaOJhF.jpg", - "https://i.imgur.com/SS0edvc.jpg", - "https://i.imgur.com/T41LFTl.png", - "https://i.imgur.com/BxZaxCM.png", - "https://i.imgur.com/8kdR6Pn.png", - "https://i.imgur.com/Ygt9WwI.jpg", - "https://i.imgur.com/8sUZzzf.jpg", - "https://i.imgur.com/m160og9.jpg", - "https://i.imgur.com/HharYbL.jpg", - "https://i.imgur.com/hroKoWi.jpg", - "https://i.imgur.com/NWxk4Lu.jpg", - "https://i.imgur.com/SUFg7LM.png", - "https://i.imgur.com/lcmlAlK.png", - "https://i.imgur.com/dCJItk8.jpg", - "https://i.imgur.com/iSzuoCl.jpg", - "https://i.imgur.com/PjfSo5K.jpg", - "https://i.imgur.com/Ln88AEW.png", - "https://i.imgur.com/1IX39AP.gif", - "https://i.imgur.com/AYu5QF1.png", - "https://i.imgur.com/dAvcP4K.png", - "https://i.imgur.com/tsul2xB.jpg", - "https://i.imgur.com/pESXaS0.jpg" -] diff --git a/assets/json/xiao.json b/assets/json/xiao.json deleted file mode 100644 index 5a251047..00000000 --- a/assets/json/xiao.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - "https://i.imgur.com/qZYuM84.jpg", - "https://i.imgur.com/shfH7Rn.png", - "https://i.imgur.com/wneFRY7.jpg", - "https://i.imgur.com/MpQgKHU.jpg", - "https://i.imgur.com/guJ29wp.png", - "https://i.imgur.com/a4TsRS1.jpg", - "https://i.imgur.com/w2rmDfM.jpg", - "https://i.imgur.com/DyW1DJ0.jpg", - "https://i.imgur.com/iB6durw.png", - "https://i.imgur.com/hstWdiN.jpg", - "https://i.imgur.com/HLJXkQk.jpg", - "https://i.imgur.com/x8cA0Mw.jpg", - "https://i.imgur.com/8WdAvPk.jpg", - "https://i.imgur.com/RFSSvbE.jpg", - "https://i.imgur.com/Ih2Fbbh.png", - "https://i.imgur.com/DcTADmq.jpg", - "https://i.imgur.com/IQIMmZV.jpg", - "https://i.imgur.com/zqXl6TB.gif", - "https://i.imgur.com/otIT53z.jpg", - "https://i.imgur.com/yvBlxxP.png", - "https://i.imgur.com/2Kiz3Jq.jpg", - "https://i.imgur.com/kG6Qp9U.jpg", - "https://i.imgur.com/JK66QjX.jpg", - "https://i.imgur.com/fFsF6m7.jpg", - "https://i.imgur.com/YqZmeyA.jpg", - "https://i.imgur.com/wTn8ohi.jpg", - "https://i.imgur.com/a3rIasf.jpg", - "https://i.imgur.com/09VUIGr.jpg" -] diff --git a/commands/random/fidget.js b/commands/random/fidget.js index e987fba6..2467ed52 100644 --- a/commands/random/fidget.js +++ b/commands/random/fidget.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const nimbats = require('../../assets/json/fidget'); +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class FidgetCommand extends Command { constructor(client) { @@ -13,7 +13,12 @@ module.exports = class FidgetCommand extends Command { }); } - run(msg) { - return msg.say({ files: [nimbats[Math.floor(Math.random() * nimbats.length)]] }); + async run(msg) { + try { + const nimbat = await randomFromImgurAlbum('DuO1T'); + return msg.say({ files: [nimbat] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } } }; diff --git a/commands/random/pikachu.js b/commands/random/pikachu.js index 2e20d5b3..5b6c40cc 100644 --- a/commands/random/pikachu.js +++ b/commands/random/pikachu.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const pikachus = require('../../assets/json/pikachu'); +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class PikachuCommand extends Command { constructor(client) { @@ -13,7 +13,12 @@ module.exports = class PikachuCommand extends Command { }); } - run(msg) { - return msg.say({ files: [pikachus[Math.floor(Math.random() * pikachus.length)]] }); + 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!`); + } } }; diff --git a/commands/random/xiao.js b/commands/random/xiao.js index d108fd7b..8ea85042 100644 --- a/commands/random/xiao.js +++ b/commands/random/xiao.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const xiaos = require('../../assets/json/xiao'); +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class XiaoCommand extends Command { constructor(client) { @@ -13,7 +13,12 @@ module.exports = class XiaoCommand extends Command { }); } - run(msg) { - return msg.say({ files: [xiaos[Math.floor(Math.random() * xiaos.length)]] }); + async run(msg) { + try { + const xiao = await randomFromImgurAlbum('S4e3r'); + return msg.say({ files: [xiao] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } } }; diff --git a/commands/roleplay/break-up.js b/commands/roleplay/break-up.js index 204f77f7..85294e0d 100644 --- a/commands/roleplay/break-up.js +++ b/commands/roleplay/break-up.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/1e6QRWk.gif', - 'https://i.imgur.com/hyteoA9.gif', - 'https://i.imgur.com/wT6357t.gif', - 'https://i.imgur.com/gyewxtI.gif', - 'https://i.imgur.com/rjcbrWc.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class BreakUpCommand extends Command { constructor(client) { @@ -26,10 +19,12 @@ module.exports = class BreakUpCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** breaks up with **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/cuddle.js b/commands/roleplay/cuddle.js index 14d20685..81d294d6 100644 --- a/commands/roleplay/cuddle.js +++ b/commands/roleplay/cuddle.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/JbkXFWy.gif', - 'https://i.imgur.com/LEVJfhI.gif', - 'https://i.imgur.com/WaJDnnS.gif', - 'https://i.imgur.com/wu4Xkpg.gif', - 'https://i.imgur.com/yAqf997.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class CuddleCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class CuddleCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** cuddles with **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/eat.js b/commands/roleplay/eat.js index a250142b..1f3b2afe 100644 --- a/commands/roleplay/eat.js +++ b/commands/roleplay/eat.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/lQVyPgp.gif', - 'https://i.imgur.com/rWal7zB.gif', - 'https://i.imgur.com/DjURkgJ.gif', - 'https://i.imgur.com/NDvu9Ga.gif', - 'https://i.imgur.com/DAmSe54.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class EatCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class EatCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** eats **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/evolve.js b/commands/roleplay/evolve.js index 434cf80e..fc4572fb 100644 --- a/commands/roleplay/evolve.js +++ b/commands/roleplay/evolve.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/bWJR9Ob.gif', - 'https://i.imgur.com/xW2p3BU.gif', - 'https://i.imgur.com/cMbUiPq.gif', - 'https://i.imgur.com/r1pvaH0.gif', - 'https://i.imgur.com/kWnkgI8.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class EvolveCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class EvolveCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${user.username}** is evolving!_ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/falcon-punch.js b/commands/roleplay/falcon-punch.js index edcb908f..31258ba9 100644 --- a/commands/roleplay/falcon-punch.js +++ b/commands/roleplay/falcon-punch.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/womEZVC.gif', - 'https://i.imgur.com/uw3S3hq.gif', - 'https://i.imgur.com/CVPT9ii.gif', - 'https://i.imgur.com/wGmUAIA.gif', - 'https://i.imgur.com/2HEhWdv.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class FalconPunchCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class FalconPunchCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** falcon punches **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/fist-bump.js b/commands/roleplay/fist-bump.js index 9f85346d..ab8aac9f 100644 --- a/commands/roleplay/fist-bump.js +++ b/commands/roleplay/fist-bump.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/VmawTx2.gif', - 'https://i.imgur.com/63KDI7Z.gif', - 'https://i.imgur.com/MUwliFW.gif', - 'https://i.imgur.com/DXQ1WPq.gif', - 'https://i.imgur.com/VzhQN0F.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class FistBumpCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class FistBumpCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** fist-bumps **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/high-five.js b/commands/roleplay/high-five.js index c30959d3..3d149bac 100644 --- a/commands/roleplay/high-five.js +++ b/commands/roleplay/high-five.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/YvbhAML.gif', - 'https://i.imgur.com/LOWtASy.gif', - 'https://i.imgur.com/LgtJwPW.gif', - 'https://i.imgur.com/GuLDF6b.gif', - 'https://i.imgur.com/2DdIR5H.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class HighFiveCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class HighFiveCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** high-fives **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/hit-with-shovel.js b/commands/roleplay/hit-with-shovel.js index be5c28b9..238f5ca7 100644 --- a/commands/roleplay/hit-with-shovel.js +++ b/commands/roleplay/hit-with-shovel.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class HitWithShovelCommand extends Command { constructor(client) { @@ -18,10 +18,12 @@ module.exports = class HitWithShovelCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** hits **${user.username}** with a shovel._ - https://i.imgur.com/XDIUq02.gif - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/hug.js b/commands/roleplay/hug.js index 8ba8d23d..7f6727f1 100644 --- a/commands/roleplay/hug.js +++ b/commands/roleplay/hug.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/yb29pZP.gif', - 'https://i.imgur.com/uLL4nHN.gif', - 'https://i.imgur.com/4pWi9tx.gif', - 'https://i.imgur.com/2BiHTef.gif', - 'https://i.imgur.com/lSyjOHL.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class HugCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class HugCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** hugs **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/inhale.js b/commands/roleplay/inhale.js index c903119a..d46bb7a1 100644 --- a/commands/roleplay/inhale.js +++ b/commands/roleplay/inhale.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/uUUk2kS.gif', - 'https://i.imgur.com/7C2v3yS.gif', - 'https://i.imgur.com/zsuMeQQ.gif', - 'https://i.imgur.com/kiqXxB6.gif', - 'https://i.imgur.com/0cK6zPg.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class InhaleCommand extends Command { constructor(client) { @@ -25,10 +18,15 @@ module.exports = class InhaleCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** inhales **${user.username}** but gained no ability..._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/kill.js b/commands/roleplay/kill.js index 4371644d..1d391e75 100644 --- a/commands/roleplay/kill.js +++ b/commands/roleplay/kill.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class KillCommand extends Command { constructor(client) { @@ -18,10 +18,12 @@ module.exports = class KillCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** kills **${user.username}**._ - https://i.imgur.com/KqWkaTf.gif - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/kiss.js b/commands/roleplay/kiss.js index 05f5e8e6..e89cfd2a 100644 --- a/commands/roleplay/kiss.js +++ b/commands/roleplay/kiss.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/Omge3Sb.gif', - 'https://i.imgur.com/KbfdOol.gif', - 'https://i.imgur.com/mWJAkhD.gif', - 'https://i.imgur.com/14j8ZkP.gif', - 'https://i.imgur.com/IXx6GyJ.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class KissCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class KissCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** kisses **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/marry.js b/commands/roleplay/marry.js index 5610a0ef..b350c310 100644 --- a/commands/roleplay/marry.js +++ b/commands/roleplay/marry.js @@ -1,11 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/uz4k1qI.gif', - 'https://i.imgur.com/jSlUKbw.gif', - 'https://i.imgur.com/4LMEw0M.gif', - 'https://i.imgur.com/BbXQqn1.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class MarryCommand extends Command { constructor(client) { @@ -24,10 +18,12 @@ module.exports = class MarryCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** marries **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/pat.js b/commands/roleplay/pat.js index 8bd692ec..a701e1b1 100644 --- a/commands/roleplay/pat.js +++ b/commands/roleplay/pat.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/vNEN1CC.gif', - 'https://i.imgur.com/iWC1ZLa.gif', - 'https://i.imgur.com/APxZpnT.gif', - 'https://i.imgur.com/uwbx4lE.gif', - 'https://i.imgur.com/p0AzUqV.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class PatCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class PatCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** pats **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/poke.js b/commands/roleplay/poke.js index 93114d15..aee81e9e 100644 --- a/commands/roleplay/poke.js +++ b/commands/roleplay/poke.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/argcQ0p.gif', - 'https://i.imgur.com/2QnSTJv.gif', - 'https://i.imgur.com/W5ooaKk.gif', - 'https://i.imgur.com/kpGGGie.gif', - 'https://i.imgur.com/d35YfMo.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class PokeCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class PokeCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** pokes **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/punch.js b/commands/roleplay/punch.js index e5880bb6..3100903e 100644 --- a/commands/roleplay/punch.js +++ b/commands/roleplay/punch.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/ihGcwnE.gif', - 'https://i.imgur.com/urpt2DJ.gif', - 'https://i.imgur.com/GbWuvMe.gif', - 'https://i.imgur.com/Txc5SoK.gif', - 'https://i.imgur.com/pzUmHEm.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class PunchCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class PunchCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** punches **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/slap.js b/commands/roleplay/slap.js index 505432ad..2eb438ab 100644 --- a/commands/roleplay/slap.js +++ b/commands/roleplay/slap.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/bNw8icN.gif', - 'https://i.imgur.com/wvQZQSs.gif', - 'https://i.imgur.com/ib0G51r.gif', - 'https://i.imgur.com/y7zW1gc.gif', - 'https://i.imgur.com/vHRiZDg.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class SlapCommand extends Command { constructor(client) { @@ -25,10 +18,12 @@ module.exports = class SlapCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** slaps **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/commands/roleplay/tackle.js b/commands/roleplay/tackle.js index db237baf..fb4deee2 100644 --- a/commands/roleplay/tackle.js +++ b/commands/roleplay/tackle.js @@ -1,12 +1,5 @@ const { Command } = require('discord.js-commando'); -const { stripIndents } = require('common-tags'); -const gifs = [ - 'https://i.imgur.com/988Y889.gif', - 'https://i.imgur.com/wxnNRmS.gif', - 'https://i.imgur.com/FDvkjzn.gif', - 'https://i.imgur.com/CkHHmd7.gif', - 'https://i.imgur.com/Wispo2E.gif' -]; +const { randomFromImgurAlbum } = require('../../util/Util'); module.exports = class TackleCommand extends Command { constructor(client) { @@ -26,10 +19,12 @@ module.exports = class TackleCommand extends Command { }); } - run(msg, { user }) { - return msg.say(stripIndents` - _**${msg.author.username}** tackles **${user.username}**._ - ${gifs[Math.floor(Math.random() * gifs.length)]} - `); + async run(msg, { user }) { + try { + 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!`); + } } }; diff --git a/package.json b/package.json index 2a78ecc9..cdb256af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "66.8.0", + "version": "66.8.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/util/Util.js b/util/Util.js index e0376819..7936b8c7 100644 --- a/util/Util.js +++ b/util/Util.js @@ -1,4 +1,6 @@ +const snekfetch = require('snekfetch'); const crypto = require('crypto'); +const { IMGUR_KEY } = process.env; const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea']; const no = ['no', 'n', 'nah', 'nope']; @@ -60,6 +62,14 @@ class Util { return crypto.createHash(algorithm).update(text).digest('hex'); } + static async randomFromImgurAlbum(album) { + const { body } = await snekfetch + .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 cleanXML(text) { return text .replace(/
/g, '')