tweaks and trying to add a command
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
auth.json
|
auth.json
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
.idea
|
110
bot.js
110
bot.js
@@ -11,17 +11,15 @@ var channel = null;
|
|||||||
|
|
||||||
// available commands
|
// available commands
|
||||||
function availableCommands() {
|
function availableCommands() {
|
||||||
var commands = "Available commands: " +
|
return "Available commands: " +
|
||||||
"\n**[SFW]** b.<*coinflip, 8ball, roll, compute, bunny, dankmemes, meirl, animemes, moe, moe-boys, hotguys , kgirls, kboys*>" +
|
"\n**[SFW]** b.<*coinflip, 8ball, roll, compute, 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*>" +
|
||||||
"\nFor more information on a command, you may use: *b.help <command>*";
|
"\nFor more information on a command, you may use: *b.help <command>*";
|
||||||
|
|
||||||
return commands;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// help commands
|
// help commands
|
||||||
function commandsHelp(requestedCommand) {
|
function commandsHelp(requestedCommand) {
|
||||||
var commands = {"coinflip": "**coinflip:** Returns a result of heads or tails.",
|
var commands = {"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])",
|
||||||
"compute": "**compute:** Uses WolframAlpha to process the question asked.",
|
"compute": "**compute:** Uses WolframAlpha to process the question asked.",
|
||||||
@@ -56,7 +54,7 @@ function commandsHelp(requestedCommand) {
|
|||||||
|
|
||||||
// coin flip
|
// coin flip
|
||||||
function coinFlip() {
|
function coinFlip() {
|
||||||
return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
|
return (Math.floor(Math.random() * 2) === 0) ? 'heads' : 'tails';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8 ball
|
// 8 ball
|
||||||
@@ -68,7 +66,7 @@ function eightBall() {
|
|||||||
'Sorry, bucko.', 'Hell, yes.', 'Hell to the no.', 'The future is bleak.',
|
'Sorry, bucko.', 'Hell, yes.', 'Hell to the no.', 'The future is bleak.',
|
||||||
'The future is uncertain.', 'I would rather not say.', 'Who cares?',
|
'The future is uncertain.', 'I would rather not say.', 'Who cares?',
|
||||||
'Possibly.', 'Never, ever, ever.', 'There is a small chance.', 'Yes!'];
|
'Possibly.', 'Never, ever, ever.', 'There is a small chance.', 'Yes!'];
|
||||||
|
|
||||||
return answers[(Math.floor(Math.random() * answers.length))];
|
return answers[(Math.floor(Math.random() * answers.length))];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ function stupidQuestion() {
|
|||||||
'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?',
|
||||||
'How about a good question instead?', 'Only good questions please',
|
'How about a good question instead?', 'Only good questions please',
|
||||||
'Oh god, is that a question?', 'Are you dumb because that\'s a dumb question.'];
|
'Oh god, is that a question?', 'Are you dumb because that\'s a dumb question.'];
|
||||||
|
|
||||||
return answers[(Math.floor(Math.random() * answers.length))];
|
return answers[(Math.floor(Math.random() * answers.length))];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +103,10 @@ function imgurRequest(subreddit, page_max)
|
|||||||
|
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
var returnText = "";
|
var 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")
|
||||||
{
|
{
|
||||||
@@ -116,9 +114,9 @@ function imgurRequest(subreddit, page_max)
|
|||||||
returnText = json.data[getRandomInt(0,json.data.length-1)].link;
|
returnText = json.data[getRandomInt(0,json.data.length-1)].link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
req.open("GET", request_url, false);
|
req.open("GET", request_url, false);
|
||||||
req.setRequestHeader('Authorization', 'Client-ID ' + auth.imgur);
|
req.setRequestHeader('Authorization', 'Client-ID ' + auth.imgur);
|
||||||
req.send();
|
req.send();
|
||||||
|
|
||||||
@@ -136,9 +134,9 @@ function subredditRequest(subreddit)
|
|||||||
|
|
||||||
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);
|
var json = JSON.parse(req.responseText);
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
@@ -153,11 +151,12 @@ function subredditRequest(subreddit)
|
|||||||
}
|
}
|
||||||
catch (error) // error parsing json
|
catch (error) // error parsing json
|
||||||
{
|
{
|
||||||
continue;
|
// Ignore the error and continue.
|
||||||
|
// continue; <-- last line in the loop... so does nothing.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
req.open("GET", redditURL, false);
|
req.open("GET", redditURL, false);
|
||||||
req.send();
|
req.send();
|
||||||
@@ -176,7 +175,7 @@ function redditbooruRequest(subreddit)
|
|||||||
|
|
||||||
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);
|
var json = JSON.parse(req.responseText);
|
||||||
var imageID = getRandomInt(0, json.length);
|
var imageID = getRandomInt(0, json.length);
|
||||||
@@ -199,7 +198,7 @@ function calculate(message)
|
|||||||
|
|
||||||
req.onreadystatechange = function()
|
req.onreadystatechange = function()
|
||||||
{
|
{
|
||||||
if(req.readyState == 4 && req.status == 200)
|
if(req.readyState === 4 && req.status === 200)
|
||||||
{
|
{
|
||||||
returnText = req.responseText;
|
returnText = req.responseText;
|
||||||
}
|
}
|
||||||
@@ -212,7 +211,7 @@ function calculate(message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get random number with starting and ending number
|
// get random number with starting and ending number
|
||||||
function getRandomInt(min, max)
|
function getRandomInt(min, max)
|
||||||
{
|
{
|
||||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
}
|
}
|
||||||
@@ -249,19 +248,19 @@ function setupVoice(file, volume, voice_channel)
|
|||||||
// voice queue
|
// voice queue
|
||||||
function handlePlayQueue(connection)
|
function handlePlayQueue(connection)
|
||||||
{
|
{
|
||||||
if (playQueue.length == 0)
|
if (playQueue.length === 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentCommand = playQueue[0];
|
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)
|
||||||
@@ -288,18 +287,18 @@ client.on('ready', () => {
|
|||||||
|
|
||||||
// commands
|
// commands
|
||||||
client.on('message', message => {
|
client.on('message', message => {
|
||||||
if (message.content.substring(0, 2) == 'b.' || message.content.substring(0, 2) == 'B.') {
|
if (message.content.substring(0, 2).toUpperCase() === 'B.') {
|
||||||
var args = message.content.substring(2).split(' ');
|
var args = message.content.substring(2).split(' ');
|
||||||
var cmd = args[0];
|
var 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(' ');
|
//var message_content = message.content.substring(2).split(' ');
|
||||||
if(message_content[1] === undefined)
|
if(message.content.substring(2).split(' ')[1] === undefined)
|
||||||
{
|
{
|
||||||
message.channel.send(availableCommands());
|
message.channel.send(availableCommands());
|
||||||
}
|
}
|
||||||
@@ -363,7 +362,7 @@ client.on('message', message => {
|
|||||||
message.reply(noQuestion());
|
message.reply(noQuestion());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// SFW Generic Image commands
|
// SFW Generic Image commands
|
||||||
case 'bun':
|
case 'bun':
|
||||||
case 'bunny':
|
case 'bunny':
|
||||||
@@ -372,7 +371,7 @@ client.on('message', message => {
|
|||||||
break;
|
break;
|
||||||
case 'dankmeme':
|
case 'dankmeme':
|
||||||
case 'dankmemes':
|
case 'dankmemes':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('dankmemes') : imgurRequest('dankmemes', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('dankmemes') : imgurRequest('dankmemes', 5));
|
||||||
break;
|
break;
|
||||||
case 'source':
|
case 'source':
|
||||||
message.channel.send("BunnyBot's source code: https://git.dtam.pw/daniel/discord-bot-js");
|
message.channel.send("BunnyBot's source code: https://git.dtam.pw/daniel/discord-bot-js");
|
||||||
@@ -383,19 +382,19 @@ client.on('message', message => {
|
|||||||
|
|
||||||
// SFW Anime Image commands
|
// SFW Anime Image commands
|
||||||
case 'meirl':
|
case 'meirl':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('anime_irl') : imgurRequest('anime_irl', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('anime_irl') : imgurRequest('anime_irl', 5));
|
||||||
break;
|
break;
|
||||||
case 'animemes':
|
case 'animemes':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('animemes') : imgurRequest('animemes', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('animemes') : imgurRequest('animemes', 5));
|
||||||
break;
|
break;
|
||||||
case 'moe':
|
case 'moe':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('awwnime') : imgurRequest('awwnime', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('awwnime') : imgurRequest('awwnime', 5));
|
||||||
break;
|
break;
|
||||||
case 'moe-boys':
|
case 'moe-boys':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('cuteanimeboys') : imgurRequest('cuteanimeboys', 1));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('cuteanimeboys') : imgurRequest('cuteanimeboys', 1));
|
||||||
break;
|
break;
|
||||||
case 'hotguys':
|
case 'hotguys':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
|
||||||
break;
|
break;
|
||||||
case 'kgirls':
|
case 'kgirls':
|
||||||
var availableRequests = [
|
var availableRequests = [
|
||||||
@@ -428,26 +427,40 @@ client.on('message', message => {
|
|||||||
message.channel.send(availableRequests[Math.floor(Math.random() * availableRequests.length)]);
|
message.channel.send(availableRequests[Math.floor(Math.random() * availableRequests.length)]);
|
||||||
break;
|
break;
|
||||||
case 'hentai':
|
case 'hentai':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? imgurRequest('hentai', 5) : subredditRequest('hentai', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? imgurRequest('hentai', 5) : subredditRequest('hentai', 5));
|
||||||
break;
|
break;
|
||||||
case 'yaoi':
|
case 'yaoi':
|
||||||
message.channel.send(imgurRequest('yaoi', 5));
|
message.channel.send(imgurRequest('yaoi', 5));
|
||||||
break;
|
break;
|
||||||
case 'yuri':
|
case 'yuri':
|
||||||
message.channel.send(imgurRequest('yuri', 5));
|
message.channel.send(imgurRequest('yuri', 5));
|
||||||
break;
|
break;
|
||||||
case 'neko':
|
case 'neko':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? imgurRequest('Nekomimi', 5) : subredditRequest('Nekomimi', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? imgurRequest('Nekomimi', 5) : subredditRequest('Nekomimi', 5));
|
||||||
break;
|
break;
|
||||||
case 'pokeporn':
|
case 'pokeporn':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('pokeporn') : redditbooruRequest('pokeporn'));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('pokeporn') : redditbooruRequest('pokeporn'));
|
||||||
break;
|
break;
|
||||||
case 'hgifs':
|
case 'hgifs':
|
||||||
message.channel.send(subredditRequest('nsfwanimegifs', 5));
|
message.channel.send(subredditRequest('nsfwanimegifs', 5));
|
||||||
break;
|
break;
|
||||||
case 'hentaibondage':
|
case 'hentaibondage':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? subredditRequest('hentaibondage') : imgurRequest('hentaibondage', 5));
|
message.channel.send((Math.floor(Math.random() * 2) === 0) ? subredditRequest('hentaibondage') : imgurRequest('hentaibondage', 5));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'summon':
|
||||||
|
var commandArgOne = message.content.substring(0, message.content.indexOf(' '));
|
||||||
|
if(commandArgOne !== undefined && commandArgOne.length > 0)
|
||||||
|
{
|
||||||
|
var redditToSummon = message.content.substring(message.content.indexOf(' ')+1);
|
||||||
|
message.channel.send(message.author + ' summons ' + redditToSummon + '*\n');
|
||||||
|
message.channel.send(subredditRequest(redditToSummon))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.reply("wut do i summon?");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// Voice commands
|
// Voice commands
|
||||||
case 'join':
|
case 'join':
|
||||||
@@ -465,28 +478,27 @@ client.on('message', message => {
|
|||||||
playQueue = [];
|
playQueue = [];
|
||||||
break;
|
break;
|
||||||
case 'airhorn':
|
case 'airhorn':
|
||||||
setupVoice('voice/mlg-airhorn.mp3', 0.4, message.member.voiceChannel);
|
setupVoice('voice/mlg-airhorn.mp3', 0.4, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'quiethorn':
|
case 'quiethorn':
|
||||||
setupVoice('voice/mlg-airhorn.mp3', 0.03, message.member.voiceChannel);
|
setupVoice('voice/mlg-airhorn.mp3', 0.03, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'weed':
|
case 'weed':
|
||||||
setupVoice('voice/smoke-weed.mp3', 0.2, message.member.voiceChannel);
|
setupVoice('voice/smoke-weed.mp3', 0.2, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'damnson':
|
case 'damnson':
|
||||||
setupVoice('voice/damnson.mp3', 0.35, message.member.voiceChannel);
|
setupVoice('voice/damnson.mp3', 0.35, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'wombo':
|
case 'wombo':
|
||||||
setupVoice('voice/wombocombo.mp3', 0.06, message.member.voiceChannel);
|
setupVoice('voice/wombocombo.mp3', 0.06, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'cena':
|
case 'cena':
|
||||||
setupVoice('voice/cena.mp3', 0.10, message.member.voiceChannel);
|
setupVoice('voice/cena.mp3', 0.10, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
case 'triple':
|
case 'triple':
|
||||||
setupVoice('voice/triple.mp3', 0.20, message.member.voiceChannel);
|
setupVoice('voice/triple.mp3', 0.20, message.member.voiceChannel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -8,6 +8,6 @@
|
|||||||
"discord.js": "^11.2.1",
|
"discord.js": "^11.2.1",
|
||||||
"ffmpeg-binaries": "^3.2.2-3",
|
"ffmpeg-binaries": "^3.2.2-3",
|
||||||
"xmlhttprequest": "^1.8.0",
|
"xmlhttprequest": "^1.8.0",
|
||||||
"node-opus": "^0.2.7"
|
"node-opus": "^0.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user