since stuff isn't deploying, did a bunch of code cleanup and logging

This commit is contained in:
Dalton
2018-12-07 19:36:30 -08:00
parent 434c34d87d
commit 68340be57c

677
bot.js
View File

@@ -11,6 +11,7 @@ var channel = null;
// available commands // available commands
function availableCommands() { function availableCommands() {
console.log('availaleCommands called.');
return "Available commands: " + return "Available commands: " +
"\n**[SFW]** b.<*coinflip, 8ball, roll, compute, summon, bunny, dankmemes, meirl, animemes, moe, moe-boys, hotguys , kgirls, kboys*>" + "\n**[SFW]** b.<*coinflip, 8ball, roll, compute, summon, bunny, dankmemes, meirl, animemes, moe, moe-boys, hotguys , kgirls, kboys*>" +
"\n**[NSFW]** b.<*lewd, ecchi, hentai, yaoi, yuri, neko, pokeporn, hgifs*>" + "\n**[NSFW]** b.<*lewd, ecchi, hentai, yaoi, yuri, neko, pokeporn, hgifs*>" +
@@ -19,7 +20,8 @@ function availableCommands() {
// help commands // help commands
function commandsHelp(requestedCommand) { function commandsHelp(requestedCommand) {
var commands = { console.log('commandsHelp called.');
let commands = {
"coinflip": "**coinflip:** Returns a result of heads or tails.", "coinflip": "**coinflip:** Returns a result of heads or tails.",
"8ball": "**8ball:** Shakes an 8 ball and returns a result.", "8ball": "**8ball:** Shakes an 8 ball and returns a result.",
"roll": "**roll:** Rolls a number between 1-100 (or a specified range [ex: b.roll 50-100])", "roll": "**roll:** Rolls a number between 1-100 (or a specified range [ex: b.roll 50-100])",
@@ -46,21 +48,32 @@ function commandsHelp(requestedCommand) {
}; };
if (commands[requestedCommand] === undefined) { if (commands[requestedCommand] === undefined) {
console.log('requestedCommand not found in map.');
return "Command not found, try entering **b.commands** for a full list of commands"; return "Command not found, try entering **b.commands** for a full list of commands";
} }
else { else {
console.log('requestedCommand found, returning requestedCommand map entry.');
return commands[requestedCommand]; return commands[requestedCommand];
} }
} }
// For now abstracting this, so we can maybe use config later.
// content should be a string or something js thinks is a string :)
function sendToBotTestingChannel(content) {
console.log(content);
client.channels.get('357365312620068874').send(content);
}
// coin flip // coin flip
function coinFlip() { function coinFlip() {
console.log('coinFlip called.');
return (Math.floor(Math.random() * 2) === 0) ? 'heads' : 'tails'; return (Math.floor(Math.random() * 2) === 0) ? 'heads' : 'tails';
} }
// 8 ball // 8 ball
function eightBall() { function eightBall() {
var answers = [ console.log('eightBall called.');
let answers = [
'Maybe.', 'Certainly not.', 'I hope so.', 'Not in your wildest dreams.', 'Maybe.', 'Certainly not.', 'I hope so.', 'Not in your wildest dreams.',
'There is a good chance.', 'Quite likely.', 'I think so.', 'I hope not.', 'There is a good chance.', 'Quite likely.', 'I think so.', 'I hope not.',
'I hope so.', 'Never!', 'Fuhgeddaboudit.', 'Ahaha! Really?!?', 'Pfft.', 'I hope so.', 'Never!', 'Fuhgeddaboudit.', 'Ahaha! Really?!?', 'Pfft.',
@@ -75,11 +88,14 @@ function eightBall() {
function numberRoll(startingRange, endingRange) { function numberRoll(startingRange, endingRange) {
startingRange = Math.ceil(startingRange); startingRange = Math.ceil(startingRange);
endingRange = Math.floor(endingRange); endingRange = Math.floor(endingRange);
console.log('numberRoll called. rolling a number inbetween ' + startingRange + ' and ' + endingRange);
return Math.floor(Math.random() * (endingRange - startingRange)) + startingRange; return Math.floor(Math.random() * (endingRange - startingRange)) + startingRange;
} }
// stupid question response // stupid question response
function stupidQuestion() { function stupidQuestion() {
console.log('someone asked a stupid question.');
let answers = [ let answers = [
'What kind of dumb question is that?', 'A real question please.', 'What kind of dumb question is that?', 'A real question please.',
'Is that supposed to be a question?', 'Who asked such a dumb question?', 'Is that supposed to be a question?', 'Who asked such a dumb question?',
@@ -90,6 +106,7 @@ function stupidQuestion() {
} }
function noQuestion() { function noQuestion() {
console.log('no question was asked.');
let answers = ['it helps to ask a question...', 'question plz.', 'where is the question?']; let answers = ['it helps to ask a question...', 'question plz.', 'where is the question?'];
return answers[(Math.floor(Math.random() * answers.length))]; return answers[(Math.floor(Math.random() * answers.length))];
@@ -102,41 +119,49 @@ function noQuestion() {
function bestEffortRequest(subpage, page_max) { function bestEffortRequest(subpage, page_max) {
let reddit_response = asyncSiteRequest("https://www.reddit.com/r/" + subpage + "/.json?show=all&count=25&limit=100", handleRedditJson); let reddit_response = asyncSiteRequest("https://www.reddit.com/r/" + subpage + "/.json?show=all&count=25&limit=100", handleRedditJson);
if(reddit_response) { return reddit_response; } if (reddit_response) {
return reddit_response;
}
let imgur_response; let imgur_response;
if(page_max) { if (page_max) {
imgur_response = imgurRequest(subpage, page_max); imgur_response = imgurRequest(subpage, page_max);
if(imgur_response) { return imgur_response } if (imgur_response) {
return imgur_response
}
} }
let redditbooru_response = redditbooruRequest(subpage); let redditbooru_response = redditbooruRequest(subpage);
if(redditbooru_response) { return redditbooru_response } if (redditbooru_response) {
return redditbooru_response
}
client.channels.get('357365312620068874').send('reddit:' + reddit_response + '\nimgur:' + imgur_response + '\nredditbooru:' + redditbooru_response); sendToBotTestingChannel('reddit:' + reddit_response + '\nimgur:' + imgur_response + '\nredditbooru:' + redditbooru_response);
return "I couldn't find that, sauce?"; return "I couldn't find that, sauce?";
} }
// imgur request // imgur request
function imgurRequest(subreddit, page_max) { function imgurRequest(subreddit, page_max) {
var multiSubreddit = subreddit.split(','); let multiSubreddit = subreddit.split(',');
var request_url = 'https://api.imgur.com/3/gallery/r/' + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + '/time/' + getRandomInt(1, page_max); let request_url = 'https://api.imgur.com/3/gallery/r/' + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + '/time/' + getRandomInt(1, page_max);
var req = new XMLHttpRequest(); let req = new XMLHttpRequest();
var returnText = ""; let returnText = "";
req.onreadystatechange = function () { req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) { if (req.readyState === 4 && req.status === 200) {
if (req.responseText !== "Not found") { if (req.responseText !== "Not found") {
try { try {
var json = JSON.parse(req.responseText); let json = JSON.parse(req.responseText);
let json_data = json.data[getRandomInt(0, json.data.length - 1)]; let json_data = json.data[getRandomInt(0, json.data.length - 1)];
if(json_data) { returnText = json_data.link; } if (json_data) {
returnText = json_data.link;
}
} catch (error) { } catch (error) {
// Ignore the error and let the calling method handle the empty string. // Ignore the error and let the calling method handle the empty string.
client.channels.get('357365312620068874').send(error.message); sendToBotTestingChannel(error.message);
} }
} }
} }
@@ -151,8 +176,8 @@ function imgurRequest(subreddit, page_max) {
// Abstracted Reddit Json media grab. // Abstracted Reddit Json media grab.
function handleRedditJson(data) { function handleRedditJson(data) {
let json = data.json(); let json = data.json();
for(i = 0; i < json.data.children.length; i++) { for (let i = 0; i < json.data.children.length; i++) {
let rand = getRandomInt(0, json.data.children.length - 1); let rand = getRandomInt(0, json.data.children.length - 1);
if (json.data.children[rand].data.post_hint === "image" || json.data.children[rand].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video") { if (json.data.children[rand].data.post_hint === "image" || json.data.children[rand].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video") {
@@ -167,29 +192,33 @@ function handleRedditJson(data) {
function asyncSiteRequest(url, process) { function asyncSiteRequest(url, process) {
fetch(url) fetch(url)
.then(data => {return process(data);}) .then(data => {
return process(data);
})
.catch(error => { .catch(error => {
client.channels.get('357365312620068874').send(error.message); sendToBotTestingChannel(error.message);
return ""; }) console.log(error.message);
return "";
})
} }
// subreddit request // subreddit request
function subredditRequest(subreddit) { function subredditRequest(subreddit) {
var multiSubreddit = subreddit.split(','); let multiSubreddit = subreddit.split(',');
var redditURL = "https://www.reddit.com/r/" + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + "/.json?show=all&count=25&limit=100"; let redditURL = "https://www.reddit.com/r/" + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + "/.json?show=all&count=25&limit=100";
var req = new XMLHttpRequest(); let req = new XMLHttpRequest();
var returnText = ""; let returnText = "";
req.onreadystatechange = function () { req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) { if (req.readyState === 4 && req.status === 200) {
var json = JSON.parse(req.responseText); let json = JSON.parse(req.responseText);
let counter = 0; let counter = 0;
while (true) { while (true) {
var i = getRandomInt(0, json.data.children.length - 1); let i = getRandomInt(0, json.data.children.length - 1);
try { try {
counter++; counter++;
@@ -203,10 +232,12 @@ function subredditRequest(subreddit) {
{ {
// Ignore the error and continue. // Ignore the error and continue.
// continue; <-- last line in the loop... so does nothing. // continue; <-- last line in the loop... so does nothing.
client.channels.get('357365312620068874').send(error.message); sendToBotTestingChannel(error.message);
} }
if(counter > 5) { break; }g if (counter > 5) {
break;
}
} }
} }
}; };
@@ -219,16 +250,16 @@ function subredditRequest(subreddit) {
// redditbooru request // redditbooru request
function redditbooruRequest(subreddit) { function redditbooruRequest(subreddit) {
var multiSubreddit = subreddit.split(','); let multiSubreddit = subreddit.split(',');
var url = "https://" + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + ".redditbooru.com/images/?limit=1000"; let url = "https://" + multiSubreddit[getRandomInt(0, multiSubreddit.length - 1)] + ".redditbooru.com/images/?limit=1000";
var req = new XMLHttpRequest(); let req = new XMLHttpRequest();
var returnText = ""; let returnText = "";
req.onreadystatechange = function () { req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) { if (req.readyState === 4 && req.status === 200) {
var json = JSON.parse(req.responseText); let json = JSON.parse(req.responseText);
var imageID = getRandomInt(0, json.length); let imageID = getRandomInt(0, json.length);
returnText = json[imageID].cdnUrl; returnText = json[imageID].cdnUrl;
} }
}; };
@@ -241,9 +272,9 @@ function redditbooruRequest(subreddit) {
// wolframalpha computation // wolframalpha computation
function calculate(message) { function calculate(message) {
var url = "http://api.wolframalpha.com/v1/result?appid=" + auth.wolframalpha + "&i=" + encodeURIComponent(message); let url = "http://api.wolframalpha.com/v1/result?appid=" + auth.wolframalpha + "&i=" + encodeURIComponent(message);
var req = new XMLHttpRequest(); let req = new XMLHttpRequest();
var returnText = ""; let returnText = "";
req.onreadystatechange = function () { req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) { if (req.readyState === 4 && req.status === 200) {
@@ -273,8 +304,7 @@ function setupVoice(file, volume, voice_channel) {
if (channel instanceof Discord.VoiceChannel) { if (channel instanceof Discord.VoiceChannel) {
if (!queueExists) { if (!queueExists) {
queueExists = true; queueExists = true;
channel.join().then(connection => channel.join().then(connection => {
{
handlePlayQueue(connection); handlePlayQueue(connection);
}); });
} }
@@ -292,24 +322,23 @@ function handlePlayQueue(connection) {
return; return;
} }
currentCommand = playQueue[0]; let currentCommand = playQueue[0];
const dispatcher = connection.playFile(currentCommand) const dispatcher = connection.playFile(currentCommand);
dispatcher.on("end", () => dispatcher.on("end", () => {
{
playQueue.pop(); playQueue.pop();
playVolume.pop(); playVolume.pop();
if (playQueue.length === 0) { if (playQueue.length === 0) {
queueExists = false; queueExists = false;
if (channel != null) { if (channel != null) {
channel.leave(); channel.leave();
channel = null; channel = null;
}
} }
} else {
else { handlePlayQueue(connection);
handlePlayQueue(connection); }
} })
})
; ;
dispatcher.setVolume(playVolume[0]); dispatcher.setVolume(playVolume[0]);
} }
@@ -318,294 +347,300 @@ function handlePlayQueue(connection) {
const client = new Discord.Client(); const client = new Discord.Client();
client.on('ready', () => { client.on('ready', () => {
console.log('Bot is ready'); console.log('Bot is ready');
// update status // update status
var availableTypes = ['PLAYING', 'LISTENING', 'WATCHING']; let availableTypes = ['PLAYING', 'LISTENING', 'WATCHING'];
var setType = availableTypes[Math.floor(Math.random() * availableTypes.length)]; let setType = availableTypes[Math.floor(Math.random() * availableTypes.length)];
var setStatus; let setStatus;
let availableStatus;
switch (setType) { switch (setType) {
case 'PLAYING': case 'PLAYING':
var availableStatus = ['with cute bunnies', 'with bunny toys', 'in bunny heaven', 'with my pet bunny', 'with all the bunnies']; availableStatus = ['with cute bunnies', 'with bunny toys', 'in bunny heaven', 'with my pet bunny', 'with all the bunnies'];
setStatus = availableStatus[Math.floor(Math.random() * availableStatus.length)]; break;
break; case 'LISTENING':
case 'LISTENING': availableStatus = ['to cute bunnies', 'to adorable bunnies eating', 'to bunnies playing with toys', 'to bunnies pouting'];
var availableStatus = ['to cute bunnies', 'to adorable bunnies eating', 'to bunnies playing with toys', 'to bunnies pouting']; break;
setStatus = availableStatus[Math.floor(Math.random() * availableStatus.length)]; case 'WATCHING':
break; availableStatus = ['cute bunnies', 'cute bunnies play', 'cute bunnies sleep', 'bunnies nibbling on food', 'swiftimustv'];
case 'WATCHING': break;
var availableStatus = ['cute bunnies', 'cute bunnies play', 'cute bunnies sleep', 'bunnies nibbling on food', 'swiftimustv']; }
setStatus = availableStatus[Math.floor(Math.random() * availableStatus.length)]; setStatus = availableStatus[Math.floor(Math.random() * availableStatus.length)];
break;
}
client.user.setActivity(setStatus, {type: setType}); // todo this set activity returns a promise and we aren't doing anything with it
client.user.setActivity(setStatus, {type: setType})
.catch(error => {
sendToBotTestingChannel(error.message);
console.log(error.message);
});
}) })
; ;
// commands // commands
client.on('message', message => { client.on('message', message => {
if(message.content.substring(0, 2).toUpperCase() === 'B.') { if (message.content.substring(0, 2).toUpperCase() === 'B.' || message.content.substring(0, 2) === '//') {
var args = message.content.substring(2).split(' '); let args = message.content.substring(2).split(' ');
var cmd = args[0]; let cmd = args[0];
switch (cmd) { switch (cmd) {
// Reply commands // Reply commands
case 'command': case 'command':
case 'commands': case 'commands':
case 'help': case 'help':
var message_content = message.content.substring(2).split(' '); let message_content = message.content.substring(2).split(' ');
if (message.content.substring(2).split(' ')[1] === undefined) { if (message.content.substring(2).split(' ')[1] === undefined) {
message.channel.send(availableCommands()); message.channel.send(availableCommands());
}
else {
message.channel.send(commandsHelp(message_content[1]));
}
break;
case 'coinflip':
case 'coin':
message.channel.send(message.author + ' flipped a coin, it landed on **' + coinFlip() + '!**');
break;
case '8ball':
if (message.content.substring(8).length > 0) {
message.channel.send(message.author + ' asked: *' + message.content.substring(8) + '*\n' +
'The magic 8 ball says: **' + eightBall() + '**');
}
else {
message.reply(noQuestion());
}
break;
case 'roll':
var message_content = message.content.substring(2).split(' ');
if (message_content[1] !== undefined && message_content[1].length > 0) // ranged roll
{
var regex = /^[0-9]+-[0-9]+$/;
if (regex.test(message_content[1])) {
var range_break = message_content[1].split('-');
message.channel.send(message.author + ' rolls a number between ' + range_break[0] + ' and ' + range_break[1] + '. They roll **' + numberRoll(range_break[0], range_break[1]) + '**.');
} }
else { else {
message.channel.send('Unknown roll format. Use "**b.help roll**" for more information.'); message.channel.send(commandsHelp(message_content[1]));
} }
} break;
else // default roll (1-100) case 'coinflip':
{ case 'coin':
message.channel.send(message.author + ' rolls a number between 1 and 100. They roll **' + numberRoll(1, 100) + '**.'); message.channel.send(message.author + ' flipped a coin, it landed on **' + coinFlip() + '!**');
} break;
break; case '8ball':
case 'compute': if (message.content.substring(8).length > 0) {
case 'convert': message.channel.send(message.author + ' asked: *' + message.content.substring(8) + '*\n' +
case 'calculate': 'The magic 8 ball says: **' + eightBall() + '**');
var message_content = message.content.substring(2).split(' ');
if (message_content[1] !== undefined && message_content[1].length > 0) {
var response = calculate(message.content.substring(message.content.indexOf(' ') + 1));
if (response === "") {
response = stupidQuestion();
} }
message.channel.send(message.author + ' wants to compute: *' + message.content.substring(message.content.indexOf(' ') + 1) + '*\n' + else {
'The result is: **' + response + '**') message.reply(noQuestion());
} }
else { break;
message.reply(noQuestion()); case 'roll':
} let message_content = message.content.substring(2).split(' ');
break; if (message_content[1] !== undefined && message_content[1].length > 0) // ranged roll
{
let regex = /^[0-9]+-[0-9]+$/;
if (regex.test(message_content[1])) {
let range_break = message_content[1].split('-');
// SFW Generic Image commands message.channel.send(message.author + ' rolls a number between ' + range_break[0] + ' and ' + range_break[1] + '. They roll **' + numberRoll(range_break[0], range_break[1]) + '**.');
case 'bun': }
case 'bunny': else {
case 'bunnies': message.channel.send('Unknown roll format. Use "**b.help roll**" for more information.');
message.channel.send(imgurRequest('rabbits', 5));
break;
case 'dankmeme':
case 'dankmemes':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('dankmemes') : imgurRequest('dankmemes', 5));
break;
case 'source':
message.channel.send("BunnyBot's source code: https://git.dtam.pw/daniel/discord-bot-js");
break;
case 'testcommand':
message.channel.send("testing! 3.0");
break;
// SFW Anime Image commands
case 'meirl':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('anime_irl') : imgurRequest('anime_irl', 5));
break;
case 'animemes':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('animemes') : imgurRequest('animemes', 5));
break;
case 'moe':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('awwnime') : imgurRequest('awwnime', 5));
break;
case 'moe-boys':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('cuteanimeboys') : imgurRequest('cuteanimeboys', 1));
break;
case 'hotguys':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
break;
case 'kgirls':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(redditbooruRequest('kpics'));
break;
case 1:
message.channel.send(imgurRequest('kpics', 5));
break;
case 2:
message.channel.send(subredditRequest('kpopfap'));
break;
}
break;
case 'kboys':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(imgurRequest('kfanservice', 1));
break;
case 1:
message.channel.send(imgurRequest('kpecs', 1));
break;
case 2:
message.channel.send(imgurRequest('cutekboys', 1));
break;
}
break;
// NSFW
case 'lewd':
message.channel.send(redditbooruRequest('pantsu'));
break;
case 'ecchi':
switch (Math.floor(Math.random() * 4)) {
case 0:
message.channel.send(subredditRequest('ecchi'));
break;
case 1:
message.channel.send(redditbooruRequest('ecchi'));
break;
case 2:
message.channel.send(redditbooruRequest('Sukebei'));
break;
case 3:
message.channel.send(imgurRequest('ecchi', 5));
break;
}
break;
case 'hentai':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(subredditRequest('hentai', 5));
break;
case 1:
message.channel.send(subredditRequest('hentaisource', 5));
break;
case 2:
message.channel.send(imgurRequest('hentai', 5));
break;
}
break;
case 'yaoi':
message.channel.send(imgurRequest('yaoi', 5));
break;
case 'yuri':
message.channel.send(imgurRequest('yuri', 5));
break;
case 'neko':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? imgurRequest('Nekomimi', 5) : subredditRequest('Nekomimi', 5));
break;
case 'pokeporn':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('pokeporn') : redditbooruRequest('pokeporn'));
break;
case 'hgifs':
message.channel.send(subredditRequest('nsfwanimegifs', 5));
break;
case 'hentaibondage':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('hentaibondage') : imgurRequest('hentaibondage', 5));
break;
case 'myid':
message.reply('Author is:' + message.author + '\nID is:' + message.author.id);
break;
case 'summon':
try {
// Dalton's image summon command.
// Checks for banned author's using a hard coded list of discord ids.
// Also rudely cleans garbage entries.
let banned_authors = ['143999140878090240', '517182806359801857'];
message.channel.send('isAuthorBanned:' + banned_authors.includes(message.author.id));
if (!banned_authors.includes(message.author.id)) {
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(site_response);
}
// Missing Argument
} else {
message.channel.send('wut do i summon?');
}
} }
} else {
message.channel.send("You're a bad boi and a banned author, you can't summon til you learn to behave.");
} }
} catch (error) { else // default roll (1-100)
//message.channel.send(error.stack); {
//message.channel.send(error.name); message.channel.send(message.author + ' rolls a number between 1 and 100. They roll **' + numberRoll(1, 100) + '**.');
//message.channel.send(error.message); }
client.channels.get('357365312620068874').send(error.message); break;
} case 'compute':
break; case 'convert':
case 'calculate':
let message_content = message.content.substring(2).split(' ');
if (message_content[1] !== undefined && message_content[1].length > 0) {
let response = calculate(message.content.substring(message.content.indexOf(' ') + 1));
if (response === "") {
response = stupidQuestion();
}
message.channel.send(message.author + ' wants to compute: *' + message.content.substring(message.content.indexOf(' ') + 1) + '*\n' +
'The result is: **' + response + '**')
}
else {
message.reply(noQuestion());
}
break;
// Voice commands // SFW Generic Image commands
case 'join': case 'bun':
channel = message.member.voiceChannel; case 'bunny':
channel.join(); case 'bunnies':
break; message.channel.send(imgurRequest('rabbits', 5));
case 'leave': break;
case 'stop': case 'dankmeme':
case 'skip': case 'dankmemes':
if (channel != null) { message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('dankmemes') : imgurRequest('dankmemes', 5));
channel.leave(); break;
channel = null; case 'source':
} message.channel.send("BunnyBot's source code: https://git.dtam.pw/daniel/discord-bot-js");
playQueue = []; break;
break; case 'testcommand':
case 'airhorn': message.channel.send("testing! 3.0");
setupVoice('voice/mlg-airhorn.mp3', 0.4, message.member.voiceChannel); break;
break;
case 'quiethorn':
setupVoice('voice/mlg-airhorn.mp3', 0.03, message.member.voiceChannel); // SFW Anime Image commands
break; case 'meirl':
case 'weed': message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('anime_irl') : imgurRequest('anime_irl', 5));
setupVoice('voice/smoke-weed.mp3', 0.2, message.member.voiceChannel); break;
break; case 'animemes':
case 'damnson': message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('animemes') : imgurRequest('animemes', 5));
setupVoice('voice/damnson.mp3', 0.35, message.member.voiceChannel); break;
break; case 'moe':
case 'wombo': message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('awwnime') : imgurRequest('awwnime', 5));
setupVoice('voice/wombocombo.mp3', 0.06, message.member.voiceChannel); break;
break; case 'moe-boys':
case 'cena': message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('cuteanimeboys') : imgurRequest('cuteanimeboys', 1));
setupVoice('voice/cena.mp3', 0.10, message.member.voiceChannel); break;
break; case 'hotguys':
case 'triple': message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
setupVoice('voice/triple.mp3', 0.20, message.member.voiceChannel); break;
break; case 'kgirls':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(redditbooruRequest('kpics'));
break;
case 1:
message.channel.send(imgurRequest('kpics', 5));
break;
case 2:
message.channel.send(subredditRequest('kpopfap'));
break;
}
break;
case 'kboys':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(imgurRequest('kfanservice', 1));
break;
case 1:
message.channel.send(imgurRequest('kpecs', 1));
break;
case 2:
message.channel.send(imgurRequest('cutekboys', 1));
break;
}
break;
// NSFW
case 'lewd':
message.channel.send(redditbooruRequest('pantsu'));
break;
case 'ecchi':
switch (Math.floor(Math.random() * 4)) {
case 0:
message.channel.send(subredditRequest('ecchi'));
break;
case 1:
message.channel.send(redditbooruRequest('ecchi'));
break;
case 2:
message.channel.send(redditbooruRequest('Sukebei'));
break;
case 3:
message.channel.send(imgurRequest('ecchi', 5));
break;
}
break;
case 'hentai':
switch (Math.floor(Math.random() * 3)) {
case 0:
message.channel.send(subredditRequest('hentai', 5));
break;
case 1:
message.channel.send(subredditRequest('hentaisource', 5));
break;
case 2:
message.channel.send(imgurRequest('hentai', 5));
break;
}
break;
case 'yaoi':
message.channel.send(imgurRequest('yaoi', 5));
break;
case 'yuri':
message.channel.send(imgurRequest('yuri', 5));
break;
case 'neko':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? imgurRequest('Nekomimi', 5) : subredditRequest('Nekomimi', 5));
break;
case 'pokeporn':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('pokeporn') : redditbooruRequest('pokeporn'));
break;
case 'hgifs':
message.channel.send(subredditRequest('nsfwanimegifs', 5));
break;
case 'hentaibondage':
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('hentaibondage') : imgurRequest('hentaibondage', 5));
break;
case 'myid':
message.reply('Author is:' + message.author + '\nID is:' + message.author.id);
break;
case 'summon':
try {
// Dalton's image summon command.
// Checks for banned author's using a hard coded list of discord ids.
// Also rudely cleans garbage entries.
let banned_authors = ['143999140878090240', '517182806359801857'];
message.channel.send('isAuthorBanned:' + banned_authors.includes(message.author.id));
if (!banned_authors.includes(message.author.id)) {
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(site_response);
}
// Missing Argument
} else {
message.channel.send('wut do i summon?');
}
}
} else {
message.channel.send("You're a bad boi and a banned author, you can't summon til you learn to behave.");
}
} catch (error) {
//message.channel.send(error.stack);
//message.channel.send(error.name);
//message.channel.send(error.message);
sendToBotTestingChannel(error.message);
}
break;
// Voice commands
case 'join':
channel = message.member.voiceChannel;
channel.join();
break;
case 'leave':
case 'stop':
case 'skip':
if (channel != null) {
channel.leave();
channel = null;
}
playQueue = [];
break;
case 'airhorn':
setupVoice('voice/mlg-airhorn.mp3', 0.4, message.member.voiceChannel);
break;
case 'quiethorn':
setupVoice('voice/mlg-airhorn.mp3', 0.03, message.member.voiceChannel);
break;
case 'weed':
setupVoice('voice/smoke-weed.mp3', 0.2, message.member.voiceChannel);
break;
case 'damnson':
setupVoice('voice/damnson.mp3', 0.35, message.member.voiceChannel);
break;
case 'wombo':
setupVoice('voice/wombocombo.mp3', 0.06, message.member.voiceChannel);
break;
case 'cena':
setupVoice('voice/cena.mp3', 0.10, message.member.voiceChannel);
break;
case 'triple':
setupVoice('voice/triple.mp3', 0.20, message.member.voiceChannel);
break;
}
} }
}
}) })
; ;
// login // login
client.login(auth.token); client.login(auth.token)
.catch(error => console.log(error));