From f4d0c422a6a7e4dccde2df6443b60d9ba67d52fe Mon Sep 17 00:00:00 2001 From: Dalton Date: Thu, 6 Dec 2018 22:45:20 -0800 Subject: [PATCH] undid refactor --- bot.js | 60 +++++++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/bot.js b/bot.js index fafff12..fe17594 100644 --- a/bot.js +++ b/bot.js @@ -116,37 +116,6 @@ function bestEffortRequest(subpage, page_max) { return "I couldn't find that, sauce?"; } -// Dalton's image summon command. -// Checks for banned author's using a hard coded list of discord ids. -// Also rudely cleans garbage entries. -function summonCommand() { - let bannedAuthors = ['143999140878090240']; - if (bannedAuthors.contains(message.author)) { - - let messageSplit = message.content.substring(2).split(' '); - if (messageSplit.length >= 2) { - let redditToSummon = messageSplit[1].replace(/[^a-zA-Z0-9_\-]+/g, ""); - - // Valid Argument - if (redditToSummon) { - - message.channel.send(message.author + ' summons *' + redditToSummon + '*\n'); - let site_response = bestEffortRequest(redditToSummon, 5); - - if (site_response) { - message.channel.send(redditResponse); - } - - // Missing Argument - } else { - message.reply("wut do i summon?"); - } - } - } else { - message.reply("You're a bad boi and a banned author, you can't summon til you learn to behave.") - } -} - // imgur request function imgurRequest(subreddit, page_max) { var multiSubreddit = subreddit.split(','); @@ -516,7 +485,34 @@ client.on('message', message => { break; case 'summon': - summonCommand(); + // Dalton's image summon command. + // Checks for banned author's using a hard coded list of discord ids. + // Also rudely cleans garbage entries. + let bannedAuthors = ['143999140878090240']; + if (bannedAuthors.contains(message.author)) { + + let messageSplit = message.content.substring(2).split(' '); + if (messageSplit.length >= 2) { + let redditToSummon = messageSplit[1].replace(/[^a-zA-Z0-9_\-]+/g, ""); + + // Valid Argument + if (redditToSummon) { + + message.channel.send(message.author + ' summons *' + redditToSummon + '*\n'); + let site_response = bestEffortRequest(redditToSummon, 5); + + if (site_response) { + message.channel.send(redditResponse); + } + + // Missing Argument + } else { + message.reply("wut do i summon?"); + } + } + } else { + message.reply("You're a bad boi and a banned author, you can't summon til you learn to behave.") + } break; // Voice commands