more bad dalton coding fixes

This commit is contained in:
Dalton
2018-12-06 22:50:22 -08:00
parent f4d0c422a6
commit fd36596b71

46
bot.js
View File

@@ -485,33 +485,39 @@ client.on('message', message => {
break; break;
case 'summon': case 'summon':
// Dalton's image summon command. try {
// Checks for banned author's using a hard coded list of discord ids. // Dalton's image summon command.
// Also rudely cleans garbage entries. // Checks for banned author's using a hard coded list of discord ids.
let bannedAuthors = ['143999140878090240']; // Also rudely cleans garbage entries.
if (bannedAuthors.contains(message.author)) { let banned_authors = ['143999140878090240'];
if (banned_authors.includes(message.author)) {
let messageSplit = message.content.substring(2).split(' '); let messageSplit = message.content.substring(2).split(' ');
if (messageSplit.length >= 2) { if (messageSplit.length >= 2) {
let redditToSummon = messageSplit[1].replace(/[^a-zA-Z0-9_\-]+/g, ""); let redditToSummon = messageSplit[1].replace(/[^a-zA-Z0-9_\-]+/g, "");
// Valid Argument // Valid Argument
if (redditToSummon) { if (redditToSummon) {
message.channel.send(message.author + ' summons *' + redditToSummon + '*\n'); message.channel.send(message.author + ' summons *' + redditToSummon + '*\n');
let site_response = bestEffortRequest(redditToSummon, 5); let site_response = bestEffortRequest(redditToSummon, 5);
if (site_response) { if (site_response) {
message.channel.send(redditResponse); message.channel.send(redditResponse);
}
// Missing Argumentg
} else {
message.reply("wut do i summon?");
} }
// 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.")
} }
} else { } catch (error) {
message.reply("You're a bad boi and a banned author, you can't summon til you learn to behave.") message.channel.send(error.stack);
message.channel.send(error.name);
message.channel.send(error.message);
} }
break; break;