Bugtesting for 2.0 release

This commit is contained in:
plane000
2018-06-18 20:08:53 +01:00
parent 95ff57ea6f
commit ceedb3b277
11 changed files with 255 additions and 52 deletions

View File

@@ -39,6 +39,10 @@ module.exports.loadCommands = function() {
addCommand('HUG', 'hug', undefined, 'hug', 'Sends cutest hugs', false, Commands.hug);
addCommand('Pallet', 'pallet', undefined, 'pallet [number of colours]', 'Returns a random colour palet with the amount of colours specified (2-7)', false, Commands.pallet);
addCommand('QR Code', 'qr', undefined, 'qr [string]', 'Generates a QR code from the string of text provided', false, Commands.qr);
addCommand('Is', 'is', undefined, 'is [thing]', 'Determains wheather a thing is a thing or not', false, Commands.is);
addCommand('Are', 'are', undefined, 'are [things a thing]', 'Determains wheather some things are things or not', false, Commands.are);
addCommand('YEET', 'yeet', undefined, 'yeet', 'Y E E T', false, Commands.YEET);
addCommand('DABBBBB', 'dab', undefined, 'dab', 'dabs on the h8rz', false, Commands.dab);
//rule commands
addCommand('Rules', 'rules', undefined, 'rules', 'Returns all the rules for the server the command was issued in', false, MultiServerCommands.rules);
@@ -70,4 +74,6 @@ module.exports.loadCommands = function() {
addCommand('Set Prefix', 'setprefix', undefined, 'setprefix [new prefix]', 'Changes Jeffery\'s prefix in the server it was issued in to the new prefix', true, AdminCommands.setprefix);
addCommand('Set Game', 'setgame', undefined, 'setgame [new game]', 'Changes Jeffery\'s game to the new game', true, AdminCommands.setgame);
addCommand('Dump Roles', 'dumproles', undefined, 'dumproles', 'Dumps the servers roles and their ID\'s', false, AdminCommands.dumpRoles);
addCommand('Output Servers Config', 'serverconfig', undefined, 'serverconfig', 'Dumps the server config file, only issuable by the bot owner themself', true, AdminCommands.serverconfig);
}

View File

@@ -7,17 +7,17 @@ const Helper = require('../helper.js');
/*message object, messaage full, message args, discord client*/
module.exports.addadminrole = async function(message, msg, args, discordclient) {
module.exports.addadminrole = function(message, msg, args, discordclient) {
}
module.exports.stop = async function(message, msg, args, discordclient) {
module.exports.stop = function(message, msg, args, discordclient) {
message.channel.send(':white_check_mark: \`Disconnected...\`');
Logger.failed('Disconnected');
discordclient.destroy();
}
module.exports.reload = async function(message, msg, args, discordclient) {
module.exports.reload = function(message, msg, args, discordclient) {
try {
Config.loadFromFile();
message.channel.send(':white_check_mark: \`Configuration reloaded...\`');
@@ -26,7 +26,7 @@ module.exports.reload = async function(message, msg, args, discordclient) {
}
}
module.exports.setprefix = async function(message, msg, args, discordclient) {
module.exports.setprefix = function(message, msg, args, discordclient) {
if (args[1]) {
let servers = Config.getservers()
servers[message.guild.id].prefix = args[1]
@@ -38,7 +38,7 @@ module.exports.setprefix = async function(message, msg, args, discordclient) {
}
}
module.exports.setgame = async function(message, msg, args, discordclient) {
module.exports.setgame = function(message, msg, args, discordclient) {
if (args[1]) {
let newGame = '';
for (let i = 1; i < args.length; i++) {
@@ -54,7 +54,7 @@ module.exports.setgame = async function(message, msg, args, discordclient) {
}
}
module.exports.dumpRoles = async function(message, msg, args, discordclient) {
module.exports.dumpRoles = function(message, msg, args, discordclient) {
let output = 'Role name | Role Snowflake ID \n---------------------------------------------------\n'
let padding = 22;
@@ -75,3 +75,34 @@ module.exports.dumpRoles = async function(message, msg, args, discordclient) {
message.channel.send('```' + output + '```');
}
module.exports.serverconfig = async function (message, msg, args, discordclient) {
if (message.author.id == Config.getconfig().OwnerID) {//bot owners id
message.channel.send('Uploading...')
let atm = new Discord.Attachment();
atm.setAttachment('./resources/servers.json', 'Servers.json');
message.channel.send(atm);
await Helper.sleep(40);
message.channel.fetchMessages({ limit: 10 })
.then((_messages) => {
let messages = _messages.array();
let counter = 0;
for (let i = 0; i < messages.length; i++) {
if (messages[i].author.id === discordclient.user.id) {
if (counter == 0) {
counter++;
} else {
messages[i].delete();
return;
}
}
}
})
.catch();
} else {
message.channel.send(':no_entry_sign: \`You are not authorized to issue this command\`')
}
}

View File

@@ -8,8 +8,9 @@ const Helper = require('../helper.js');
/*message object, messaage full, message args, discord client*/
module.exports.help = async function(message, msg, args, discordclient) {
module.exports.help = function(message, msg, args, discordclient) {
let commands = CommandManager.commands;
if (args[1]) {
if (commands[args[1].toLowerCase()]) {
let em = new Discord.RichEmbed();
@@ -27,15 +28,42 @@ module.exports.help = async function(message, msg, args, discordclient) {
message.channel.send(`:no_entry_sign: \`That command does not exist\``);
}
} else {
message.channel.send(`See a full command list at http://www.plane000.co.uk`); //temporary
let counter = 0;
let em = new Discord.RichEmbed();
em.setColor('BLUE');
em.setTitle('All commands: (Name, Usage)');
for (i in commands) {
counter++
if (counter == 25) {
break;
}
em.addField(commands[i].name + ', ' + commands[i].command, commands[i].usage);
}
message.channel.send(em);
let em1 = new Discord.RichEmbed();
em1.setColor('BLUE');
em1.setFooter('Do `help [command]` to see more information about the specified command');
counter = 0
for (i in commands) {
counter++
if (counter >= 25) {
em1.addField(commands[i].name + ', ' + commands[i].command, commands[i].usage);
}
}
message.channel.send(em1);
}
}
module.exports.say = async function(message, msg, args, discordclient) {
module.exports.say = function(message, msg, args, discordclient) {
message.channel.send(msg.slice(4, msg.length));
}
module.exports.version = async function(message, msg, args, discordclient) {
module.exports.version = function(message, msg, args, discordclient) {
let em = new Discord.RichEmbed();
em.setColor('BLUE');
em.setTitle('Version:');
@@ -43,7 +71,7 @@ module.exports.version = async function(message, msg, args, discordclient) {
message.channel.send(em);
}
module.exports.ping = async function(message, msg, args, discordclient) {
module.exports.ping = function(message, msg, args, discordclient) {
ping.promise.probe("discordapp.com", {
timeout: 10
}).then((output) => {
@@ -77,7 +105,7 @@ module.exports.dog = async function(message, msg, args, discordclient) {
message.channel.send(em);
}
module.exports.undo = async function (message, msg, args, discordclient) {
module.exports.undo = function (message, msg, args, discordclient) {
message.channel.fetchMessages({ limit: 50 })
.then((_messages) => {
let messages = _messages.array();
@@ -91,14 +119,14 @@ module.exports.undo = async function (message, msg, args, discordclient) {
.catch();
};
module.exports.hug = async function(message, msg, args, discordclient) {
module.exports.hug = function(message, msg, args, discordclient) {
let em = new Discord.RichEmbed();
em.setColor('BLUE');
em.setImage('https://cdn.discordapp.com/attachments/345580737149403146/442232811605458957/cat-instantly-hugs-plush-toy.gif');
message.channel.send(em);
}
module.exports.pallet = async function(message, msg, args, discordclient) {
module.exports.pallet = function(message, msg, args, discordclient) {
if(args[1]) {
if (args[1] <= 7) {
if (args[1] >= 2) {
@@ -132,7 +160,7 @@ module.exports.pallet = async function(message, msg, args, discordclient) {
}
}
module.exports.qr = async function(message, msg, args, discordclient) {
module.exports.qr = function(message, msg, args, discordclient) {
if (args[1]) {
message.channel.send('', new Discord.Attachment(qr.image(msg.substring(3), { type: 'png' })));
}
@@ -140,3 +168,38 @@ module.exports.qr = async function(message, msg, args, discordclient) {
message.channel.send(':no_entry_sign: \`Please provide what you want turned into a QR code\`');
}
}
module.exports.is = function(message, msg, args, discordclient) {
let thonk = Math.floor(Math.random() * 3);
if (thonk == 0) {
message.channel.send('Yes');
} else if (thonk == 1) {
message.channel.send('No');
} else {
message.channel.send('Maybe');
}
}
module.exports.are = function(message, msg, args, discordclient) {
let thonk = Math.floor(Math.random() * 3);
if (thonk == 0) {
message.channel.send('Yes');
} else if (thonk == 1) {
message.channel.send('No');
} else {
message.channel.send('Maybe');
}
}
module.exports.YEET = function(message, msg, args, discordclient) {
message.channel.send('THIS BITCH IS ***__E M P T Y__***');
}
module.exports.dab = function(message, msg, args, discordclient) {
let em = new Discord.RichEmbed();
em.setColor('BLUE');
em.setImage('https://steamuserimages-a.akamaihd.net/ugc/858355614967886347/020C871E91BC00FE277C7D58C3925CAA639F99B0/');
message.channel.send(em)
}

View File

@@ -1,12 +1,13 @@
const Discord = require('discord.js');
const fs = require('fs');
const PImage = require('pureimage');
const Config = require('../config.js');
const Helper = require('../helper.js');
/*message object, messaage full, message args, discord client*/
/*rule commands*/
module.exports.rules = async function(message, msg, args, discordclient) {
module.exports.rules = function(message, msg, args, discordclient) {
let serverName = message.guild.name;
let serverID = message.guild.id;
let serversConfig = Config.getservers();
@@ -23,7 +24,7 @@ module.exports.rules = async function(message, msg, args, discordclient) {
message.channel.send(em);
}
module.exports.rule = async function(message, msg, args, discordclient) {
module.exports.rule = function(message, msg, args, discordclient) {
let serverName = message.guild.name;
let serverID = message.guild.id;
let serversConfig = Config.getservers();
@@ -37,7 +38,7 @@ module.exports.rule = async function(message, msg, args, discordclient) {
}
}
module.exports.addrule = async function(message, msg, args, discordclient) {
module.exports.addrule = function(message, msg, args, discordclient) {
let serverName = message.guild.name;
let serverID = message.guild.id;
let serversConfig = Config.getservers();
@@ -64,7 +65,7 @@ module.exports.addrule = async function(message, msg, args, discordclient) {
message.channel.send(em);
}
module.exports.delrule = async function(message, msg, args, discordclient) {
module.exports.delrule = function(message, msg, args, discordclient) {
if (args[1]) {
let serverName = message.guild.name;
let serverID = message.guild.id;
@@ -91,7 +92,7 @@ module.exports.delrule = async function(message, msg, args, discordclient) {
}
}
module.exports.editrule = async function(message, msg, args, discordclient) {
module.exports.editrule = function(message, msg, args, discordclient) {
let serverName = message.guild.name;
let serverID = message.guild.id;
let serversConfig = Config.getservers();
@@ -118,7 +119,7 @@ module.exports.editrule = async function(message, msg, args, discordclient) {
}
/*birthday commands*/
module.exports.addbirthday = async function(message, msg, args, discordclient) {
module.exports.addbirthday = function(message, msg, args, discordclient) {
//input date is [DD/MM/YYYY] such that 14/05/2002
let birthdays = Config.getservers()[message.guild.id].birthdays;
@@ -128,7 +129,7 @@ module.exports.addbirthday = async function(message, msg, args, discordclient) {
Config.writeToFile();
}
module.exports.delbirthday = async function(message, msg, args, discordclient) {
module.exports.delbirthday = function(message, msg, args, discordclient) {
let birthdays = Config.getservers()[message.guild.id].birthdays;
@@ -137,11 +138,11 @@ module.exports.delbirthday = async function(message, msg, args, discordclient) {
Config.writeToFile();
}
module.exports.nextbirthday = async function(message, msg, args, discordclient) {
module.exports.nextbirthday = function(message, msg, args, discordclient) {
let birthdays = Config.getservers()[message.guild.id].birthdays;
}
module.exports.allbirthdays = async function(message, msg, args, discordclient) {
module.exports.allbirthdays = function(message, msg, args, discordclient) {
let birthdays = Config.getservers()[message.guild.id].birthdays;
}
@@ -253,7 +254,7 @@ module.exports.poll = async function(message, msg, args, discordclient) {
}
}
module.exports.vote = async function(message, msg, args, discordclient) {
module.exports.vote = function(message, msg, args, discordclient) {
if (polls[message.guild.id]) {
let poll = polls[message.guild.id];
let hasVoted = false;
@@ -284,7 +285,7 @@ module.exports.vote = async function(message, msg, args, discordclient) {
message.channel.send(`${message.author} voted for ${option}!`);
} else {
message.channel.send(':no_entry_sign: \`You have allready voted\`');
message.channel.send(':no_entry_sign: \`You have already voted\`');
}
} else {
message.channel.send(':no_entry_sign: \`There are no polls running at the moment, use \'poll start\' to start one\`');
@@ -324,15 +325,37 @@ module.exports.startGame = async function(message, msg, args, discordclient) {
if (!chess[message.guild.id]) {
if (args[1]) {
try {
let player1 = message.mentions.members.first();
let player1;
try {
player1 = message.mentions.members.first();
} catch (e) {
message.channel.send(':no_entry_sign: \`You have not mentioned a user to play with...\`')
return;
}
if (player1.id == message.author.id) {
message.channel.send(':no_entry_sign: \`You cannot play with yourself :(\`')
return;
}
if (player1.id == discordclient.user.id) {
message.channel.send(':no_entry_sign: \`You cannot play with me :(\`')
return;
}
await initBoard(message, message.author, player1);
let board = await drawcurrentstate(message);
let em = new Discord.RichEmbed();
em.setAuthor()
message.channel.send('```' + await drawcurrentstate(message) + '```');
em.addField()
//em.setImage(board);
message.channel.send(em);
} catch (e) {
console.log(e);
message.channel.send(':no_entry_sign: \`You have not mentioned a user to play with...\`')
}
} else {
@@ -351,8 +374,11 @@ module.exports.move = async function(message, msg, args, discordclient) {
//game logic
async function initBoard(message, p1, p2) {
async function initBoard(message, p1, p2, channelID) {
chess[message.guild.id] = {
channel: {
id: channelID
},
board: await initMatrix(8, 8, ''),
prevMoves: [],
winner: 0,
@@ -460,3 +486,11 @@ async function drawcurrentstate(message) {
return board;
}
function setupGame(guild) {
}
function disbandGame(guild) {
}

View File

@@ -9,15 +9,20 @@ const Helper = require('../helper.js');
module.exports.nextlaunch = async function(message, msg, args, discordclient) {
let url = 'https://launchlibrary.net/1.4/launch/next/1';
try {
let result = await Helper.requestPromise(url);
let launch = JSON.parse(result).launches[0];
try {
let launch = JSON.parse(result).launches[0];
let em = new Discord.RichEmbed();
em.setTitle(launch.name);
em.setColor('BLUE');
em.setAuthor('Next Launch Info:', 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/NASA_logo.svg/1200px-NASA_logo.svg.png', 'https://spaceflightnow.com/launch-schedule/');
em.setThumbnail('https://www.nasa.gov/sites/default/files/saturnv-3_0.jpg');
em.url = launch.location.pads[0].mapURL;
let em = new Discord.RichEmbed();
em.setTitle(launch.name);
em.setColor('BLUE');
em.setAuthor('Next Launch Info:', 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/NASA_logo.svg/1200px-NASA_logo.svg.png', 'https://spaceflightnow.com/launch-schedule/');
em.setThumbnail('https://www.nasa.gov/sites/default/files/saturnv-3_0.jpg');
em.url = launch.location.pads[0].mapURL;
} catch (e) {
message.channel.send(`:no_entry_sign: \`There was a problem with the API...\``);
return;
}
let result = await Helper.requestPromise(url);
let status = 'Unknown';
if (launch.status == 1) {
@@ -75,17 +80,10 @@ module.exports.nextlaunch = async function(message, msg, args, discordclient) {
message.channel.send(em);
<<<<<<< HEAD
em.addField('Agency Name:', missionagency.name, true);
em.addField('Agency Region:', missionagency.countryCode, true);
=======
} catch (e) {
message.channel.send(`:no_entry_sign: \`There was a problem with the API...\``);
}
}
>>>>>>> d2e2c160e6597833c3bdf44372777e81e32eeb97
module.exports.spaceimg = async function(message, msg, args, discordclient) {
if (args.length >= 2) {
@@ -121,12 +119,12 @@ module.exports.spaceimg = async function(message, msg, args, discordclient) {
}
}
module.exports.pictureoftheday = async function(message, msg, args, discordclient) {
module.exports.pictureoftheday = function(message, msg, args, discordclient) {
let apiKey = Config.getconfig().NASA_APIKey;
let url = 'https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY';
}
module.exports.nearearthobj = async function(message, msg, args, discordclient) {
module.exports.nearearthobj = function(message, msg, args, discordclient) {
let apiKey = Config.getconfig().NASA_APIKey;
let url = 'https://api.nasa.gov/neo/rest/v1/neo/browse?api_key=DEMO_KEY';
}

View File

@@ -33,6 +33,9 @@ module.exports.loadDefaults = function() {
config = {
Token: '[DISCORD TOKEN HERE]',
NASA_APIKey: '[NASA API KEY HERE]',
InviteLink: '[BOT INVITE LINK HERE]',
AdminLink: '[ADMIN INVITE LINK HERE]',
OwnerID: '[YOUR ID HERE]',
NowPlaying: 'RealLife.exe',
Version: '2.0.1',
};

View File

@@ -20,10 +20,20 @@ module.exports.requestPromise = async function(url) {
}
module.exports.isUserAdmin = function(message) {
let isAdmin = false;
if(Config.getservers[message.guild.id].isUserAdmin) {
if (message.author.id == Config.getconfig().OwnerID) {
return true;
}
message.author.roles.array.forEach(role => {
let r = role.id;
Config.getservers()[message.guild.id].adminroles.forEach((e) => {
if (r == e) {
return true;
}
});
});
return false;
}
module.exports.sleep = function(ms) {

View File

@@ -84,7 +84,7 @@ module.exports.welcome = function() {
|___/
`.rainbow);
console.log('Invite JefferyBot to your server! '
+ 'https://discordapp.com/api/oauth2/authorize?client_id=423592273151000576&permissions=506981494&scope=bot' .debug);
+ 'https://discordapp.com/oauth2/authorize?client_id=423592273151000576&permissions=8&scope=bot' .debug);
console.log();
}

View File

@@ -24,6 +24,9 @@ if (!fs.existsSync('resources/config.json') || !fs.existsSync('resources/servers
}
Config.loadDefaults();
Config.writeToFile();
Logger.success('Config Successfully created');
Logger.log('Add your bot token to the newly created /resources/config.json to use Jeffery');
process.exit(1);
}
catch (e) {
Logger.warn(`Could not create the config: ${e.message}`);

53
package-lock.json generated
View File

@@ -258,6 +258,11 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"jpeg-js": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.3.4.tgz",
"integrity": "sha512-6IzjQxvnlT8UlklNmDXIJMWxijULjqGrzgqc0OG7YadZdvm7KPQ1j0ehmQQHckgEWOfgpptzcnWgESovxudpTA=="
},
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
@@ -313,6 +318,11 @@
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
},
"opentype.js": {
"version": "0.4.11",
"resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-0.4.11.tgz",
"integrity": "sha1-KBojkGOcwVkxyVXY1jwUp8d3K0E="
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
@@ -327,6 +337,11 @@
"underscore": "1.9.0"
}
},
"pngjs": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.3.3.tgz",
"integrity": "sha512-1n3Z4p3IOxArEs1VRXnZ/RXdfEniAUS9jb68g58FIXMNkPJeZd+Qh4Uq7/e0LVxAQGos1eIUrqrt4FpjdnEd+Q=="
},
"prism-media": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.0.2.tgz",
@@ -337,6 +352,39 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"pureimage": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/pureimage/-/pureimage-0.1.6.tgz",
"integrity": "sha512-t74leLaXyD3VGmMbcFZNWZoHqPQNX805gHYNBCrNEVRjUkDfdlopLJnDJI9QYdhWXwtNiD02coq+NB7+CryAwg==",
"requires": {
"jpeg-js": "0.3.4",
"opentype.js": "0.4.11",
"pngjs": "3.3.3"
}
},
"pureimage-beta": {
"version": "0.0.16",
"resolved": "https://registry.npmjs.org/pureimage-beta/-/pureimage-beta-0.0.16.tgz",
"integrity": "sha1-pWLIUmOaqbM5XbU12/c+Anc8aQo=",
"requires": {
"jpeg-js": "0.0.4",
"opentype.js": "0.4.11",
"pngjs": "0.4.0",
"richtext": "0.0.4"
},
"dependencies": {
"jpeg-js": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.0.4.tgz",
"integrity": "sha1-Bqr0fv7HrwsZJKWc1pWm0rXthw4="
},
"pngjs": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-0.4.0.tgz",
"integrity": "sha1-KUBxrcGytgv9SspNvkdZvM7m/Xc="
}
}
},
"q": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
@@ -380,6 +428,11 @@
"uuid": "3.2.1"
}
},
"richtext": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/richtext/-/richtext-0.0.4.tgz",
"integrity": "sha1-3kwKJqWE2P3JJN5aajnreEazl70="
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",

View File

@@ -27,6 +27,8 @@
"http": "0.0.0",
"https": "^1.0.0",
"ping": "^0.2.2",
"pureimage": "^0.1.6",
"pureimage-beta": "0.0.16",
"qr-image": "^3.2.0",
"request": "^2.86.0",
"smartcar-unit": "^1.1.4"