Getting close to 2.0 release

This commit is contained in:
plane000
2018-06-21 18:24:08 +01:00
parent d92e2fc22c
commit 2b8f86368a
6 changed files with 60 additions and 30 deletions

24
CONTRIBUTING.md Normal file
View File

@@ -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

View File

@@ -23,3 +23,4 @@ MIT
## Contrubuters
- Ben (plane000)#8618 - Creator, maintaner
- xX_WhatsTheGeek_Xx#8606 - Contributer

View File

@@ -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);
}

View File

@@ -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,8 +183,10 @@ 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) =>
{
@@ -189,18 +197,20 @@ module.exports.poll = async function(message, msg, args, discordclient) {
}
)
.sort((a, b) => b.count - a.count)
.filter((x, i, arr) => x.count == arr[0].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 = 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);

View File

@@ -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;
}

View File

@@ -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);