diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a966773 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# Contributing + +First off, i'd like to thank you for taking the time to contribute to JefferyBot. + +When contributing or submitting pull requests follow these guidelines or your contribution will not be taken seriously. + +## Make sure your code is + +1. Functional +2. Maintainable and Scalable +3. Readable + +## Linting + +* Tabs - 2 spaces +* Same line bracing +* Honestly just look around the code base and imitate the style +* Use Let let types pls +* Use '' for string literals and if needed `` +* Keep code well commented + +## Pull requests we reject +s +* Anything from b_boy_ww \ No newline at end of file diff --git a/README.md b/README.md index b92b8f1..9b69687 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,4 @@ MIT ## Contrubuters - Ben (plane000)#8618 - Creator, maintaner +- xX_WhatsTheGeek_Xx#8606 - Contributer \ No newline at end of file diff --git a/commandmanager.js b/commandmanager.js index 82a6f9e..94cc24d 100644 --- a/commandmanager.js +++ b/commandmanager.js @@ -74,6 +74,5 @@ 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); } diff --git a/commands/multiservercommands.js b/commands/multiservercommands.js index 03160e8..0774dfd 100644 --- a/commands/multiservercommands.js +++ b/commands/multiservercommands.js @@ -151,15 +151,21 @@ let polls = {}; module.exports.poll = async function(message, msg, args, discordclient) { if (args[1] == 'start') { + //checks if there is even a question if (args[2]) { + // checks if a poll is allready running if (!polls[message.guild.id]) { + // starts poll object await startPoll(message, args); + + // makes output options string and removes end comma let options = ''; for (i in polls[message.guild.id].options) { options += polls[message.guild.id].options[i] + ', '; } options = options.substring(0, options.length - 2); + // sends poll let em = new Discord.RichEmbed(); em.setAuthor('Poll started!'); em.setColor('BLUE'); @@ -177,30 +183,34 @@ module.exports.poll = async function(message, msg, args, discordclient) { return; } } else if (args[1] == 'stop') { + // checks if a poll is running if (polls[message.guild.id]) { + // takes poll objects, determines option with the most votes and maps that to an object let results = polls[message.guild.id].votes - .map((x, i) => - { - return { - count: x, - value: polls[message.guild.id].options[i] - }; - } - ) - .sort((a, b) => b.count - a.count) - .filter((x, i, arr) => x.count == arr[0].count) - //.map(x => x.value) + .map((x, i) => + { + return { + count: x, + value: polls[message.guild.id].options[i] + }; + } + ) + .sort((a, b) => b.count - a.count) + .filter((x, i, arr) => x.count == arr[0].count); + //.map(x => x.value) let winners = ''; let votesForWinners = ''; - + + // makes winning string and adds the votes for the winners for (let i = 0; i < results.length; i++) { - winners += results[i].value + ' and '; - votesForWinners = results[i].count; + winners += results[i].value + ' and '; + votesForWinners = results[i].count; } winners = winners.substring(0, winners.length - 5); + // sends results let em = new Discord.RichEmbed(); em.setAuthor('Poll Results'); em.setColor('BLUE'); @@ -215,12 +225,16 @@ module.exports.poll = async function(message, msg, args, discordclient) { return; } } else if (args[1] == 'view') { + // checks if a poll is running if (polls[message.guild.id]) { + + // gets current poll info let poll = polls[message.guild.id]; let q = poll.pollq; let options = poll.options; let votes = poll.votes; + // bracing for votes let firstline = ''; let secondline = ' '; for(let i = 0; i < options.length; i++) { @@ -239,6 +253,7 @@ module.exports.poll = async function(message, msg, args, discordclient) { } firstline = firstline.substring(0, firstline.length - 2); + // sends message let em = new Discord.RichEmbed(); em.setAuthor(`For the question \'${q}\'`); em.setTitle('With the options and votes:'); @@ -255,6 +270,7 @@ module.exports.poll = async function(message, msg, args, discordclient) { } module.exports.vote = function(message, msg, args, discordclient) { + // checks if a poll is running if (polls[message.guild.id]) { let poll = polls[message.guild.id]; let hasVoted = false; @@ -345,14 +361,8 @@ module.exports.startGame = async function(message, msg, args, discordclient) { await initBoard(message, message.author, player1); let board = await drawcurrentstate(message); - - - let em = new Discord.RichEmbed(); - - em.addField() - //em.setImage(board); - - message.channel.send(em); + message.channel.send('```' + board + '```'); + message.channel.send(); } catch (e) { console.log(e); diff --git a/helper.js b/helper.js index e225c1b..c258242 100644 --- a/helper.js +++ b/helper.js @@ -23,7 +23,6 @@ module.exports.isUserAdmin = function(message) { 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) => { @@ -32,7 +31,6 @@ module.exports.isUserAdmin = function(message) { } }); }); - return false; } diff --git a/main.js b/main.js index 2876c25..a13ea3c 100644 --- a/main.js +++ b/main.js @@ -63,7 +63,6 @@ client.on('ready', () => { try { Logger.success('Connected to discords API'); - /*adds all servers not in config to config*/ Logger.log('Setting up the server spesific commands...') client.guilds.array().forEach((g) => { @@ -74,7 +73,6 @@ client.on('ready', () => { Config.writeToFile(); Logger.success('Server commands set up'); - Logger.log('Logging in...') client.user.setPresence('online'); client.user.setActivity(Config.getconfig().NowPlaying); @@ -130,14 +128,14 @@ client.on('guildDelete', async (guild) => { }); client.on("guildMemberAdd", async member => { - if(member.guild.id == "443095663018770432") { + if (member.guild.id == "443095663018770432") { let role = member.guild.roles.find(r => r.name === "Regular Joe"); if (!role) { Logger.log("role not found") return; }; - if(member.bot) return; - if(member.roles.find(r => r.name === "Regular Joe")) return Logger.warn("User already has role!"); + if (member.bot) return; + if (member.roles.find(r => r.name === "Regular Joe")) return Logger.warn("User already has role!"); member.addRole(role) }; });