Getting close to 2.0 release
This commit is contained in:
24
CONTRIBUTING.md
Normal file
24
CONTRIBUTING.md
Normal 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
|
||||||
@@ -23,3 +23,4 @@ MIT
|
|||||||
## Contrubuters
|
## Contrubuters
|
||||||
|
|
||||||
- Ben (plane000)#8618 - Creator, maintaner
|
- Ben (plane000)#8618 - Creator, maintaner
|
||||||
|
- xX_WhatsTheGeek_Xx#8606 - Contributer
|
||||||
@@ -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 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('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('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);
|
addCommand('Output Servers Config', 'serverconfig', undefined, 'serverconfig', 'Dumps the server config file, only issuable by the bot owner themself', true, AdminCommands.serverconfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,15 +151,21 @@ let polls = {};
|
|||||||
|
|
||||||
module.exports.poll = async function(message, msg, args, discordclient) {
|
module.exports.poll = async function(message, msg, args, discordclient) {
|
||||||
if (args[1] == 'start') {
|
if (args[1] == 'start') {
|
||||||
|
//checks if there is even a question
|
||||||
if (args[2]) {
|
if (args[2]) {
|
||||||
|
// checks if a poll is allready running
|
||||||
if (!polls[message.guild.id]) {
|
if (!polls[message.guild.id]) {
|
||||||
|
// starts poll object
|
||||||
await startPoll(message, args);
|
await startPoll(message, args);
|
||||||
|
|
||||||
|
// makes output options string and removes end comma
|
||||||
let options = '';
|
let options = '';
|
||||||
for (i in polls[message.guild.id].options) {
|
for (i in polls[message.guild.id].options) {
|
||||||
options += polls[message.guild.id].options[i] + ', ';
|
options += polls[message.guild.id].options[i] + ', ';
|
||||||
}
|
}
|
||||||
options = options.substring(0, options.length - 2);
|
options = options.substring(0, options.length - 2);
|
||||||
|
|
||||||
|
// sends poll
|
||||||
let em = new Discord.RichEmbed();
|
let em = new Discord.RichEmbed();
|
||||||
em.setAuthor('Poll started!');
|
em.setAuthor('Poll started!');
|
||||||
em.setColor('BLUE');
|
em.setColor('BLUE');
|
||||||
@@ -177,8 +183,10 @@ module.exports.poll = async function(message, msg, args, discordclient) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (args[1] == 'stop') {
|
} else if (args[1] == 'stop') {
|
||||||
|
// checks if a poll is running
|
||||||
if (polls[message.guild.id]) {
|
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
|
let results = polls[message.guild.id].votes
|
||||||
.map((x, i) =>
|
.map((x, i) =>
|
||||||
{
|
{
|
||||||
@@ -189,18 +197,20 @@ module.exports.poll = async function(message, msg, args, discordclient) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.sort((a, b) => b.count - a.count)
|
.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)
|
//.map(x => x.value)
|
||||||
|
|
||||||
let winners = '';
|
let winners = '';
|
||||||
let votesForWinners = '';
|
let votesForWinners = '';
|
||||||
|
|
||||||
|
// makes winning string and adds the votes for the winners
|
||||||
for (let i = 0; i < results.length; i++) {
|
for (let i = 0; i < results.length; i++) {
|
||||||
winners += results[i].value + ' and ';
|
winners += results[i].value + ' and ';
|
||||||
votesForWinners = results[i].count;
|
votesForWinners = results[i].count;
|
||||||
}
|
}
|
||||||
winners = winners.substring(0, winners.length - 5);
|
winners = winners.substring(0, winners.length - 5);
|
||||||
|
|
||||||
|
// sends results
|
||||||
let em = new Discord.RichEmbed();
|
let em = new Discord.RichEmbed();
|
||||||
em.setAuthor('Poll Results');
|
em.setAuthor('Poll Results');
|
||||||
em.setColor('BLUE');
|
em.setColor('BLUE');
|
||||||
@@ -215,12 +225,16 @@ module.exports.poll = async function(message, msg, args, discordclient) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (args[1] == 'view') {
|
} else if (args[1] == 'view') {
|
||||||
|
// checks if a poll is running
|
||||||
if (polls[message.guild.id]) {
|
if (polls[message.guild.id]) {
|
||||||
|
|
||||||
|
// gets current poll info
|
||||||
let poll = polls[message.guild.id];
|
let poll = polls[message.guild.id];
|
||||||
let q = poll.pollq;
|
let q = poll.pollq;
|
||||||
let options = poll.options;
|
let options = poll.options;
|
||||||
let votes = poll.votes;
|
let votes = poll.votes;
|
||||||
|
|
||||||
|
// bracing for votes
|
||||||
let firstline = '';
|
let firstline = '';
|
||||||
let secondline = ' ';
|
let secondline = ' ';
|
||||||
for(let i = 0; i < options.length; i++) {
|
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);
|
firstline = firstline.substring(0, firstline.length - 2);
|
||||||
|
|
||||||
|
// sends message
|
||||||
let em = new Discord.RichEmbed();
|
let em = new Discord.RichEmbed();
|
||||||
em.setAuthor(`For the question \'${q}\'`);
|
em.setAuthor(`For the question \'${q}\'`);
|
||||||
em.setTitle('With the options and votes:');
|
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) {
|
module.exports.vote = function(message, msg, args, discordclient) {
|
||||||
|
// checks if a poll is running
|
||||||
if (polls[message.guild.id]) {
|
if (polls[message.guild.id]) {
|
||||||
let poll = polls[message.guild.id];
|
let poll = polls[message.guild.id];
|
||||||
let hasVoted = false;
|
let hasVoted = false;
|
||||||
@@ -345,14 +361,8 @@ module.exports.startGame = async function(message, msg, args, discordclient) {
|
|||||||
await initBoard(message, message.author, player1);
|
await initBoard(message, message.author, player1);
|
||||||
let board = await drawcurrentstate(message);
|
let board = await drawcurrentstate(message);
|
||||||
|
|
||||||
|
message.channel.send('```' + board + '```');
|
||||||
|
message.channel.send();
|
||||||
let em = new Discord.RichEmbed();
|
|
||||||
|
|
||||||
em.addField()
|
|
||||||
//em.setImage(board);
|
|
||||||
|
|
||||||
message.channel.send(em);
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ module.exports.isUserAdmin = function(message) {
|
|||||||
if (message.author.id == Config.getconfig().OwnerID) {
|
if (message.author.id == Config.getconfig().OwnerID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.author.roles.array.forEach(role => {
|
message.author.roles.array.forEach(role => {
|
||||||
let r = role.id;
|
let r = role.id;
|
||||||
Config.getservers()[message.guild.id].adminroles.forEach((e) => {
|
Config.getservers()[message.guild.id].adminroles.forEach((e) => {
|
||||||
@@ -32,7 +31,6 @@ module.exports.isUserAdmin = function(message) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
main.js
8
main.js
@@ -63,7 +63,6 @@ client.on('ready', () => {
|
|||||||
try {
|
try {
|
||||||
Logger.success('Connected to discords API');
|
Logger.success('Connected to discords API');
|
||||||
|
|
||||||
|
|
||||||
/*adds all servers not in config to config*/
|
/*adds all servers not in config to config*/
|
||||||
Logger.log('Setting up the server spesific commands...')
|
Logger.log('Setting up the server spesific commands...')
|
||||||
client.guilds.array().forEach((g) => {
|
client.guilds.array().forEach((g) => {
|
||||||
@@ -74,7 +73,6 @@ client.on('ready', () => {
|
|||||||
Config.writeToFile();
|
Config.writeToFile();
|
||||||
Logger.success('Server commands set up');
|
Logger.success('Server commands set up');
|
||||||
|
|
||||||
|
|
||||||
Logger.log('Logging in...')
|
Logger.log('Logging in...')
|
||||||
client.user.setPresence('online');
|
client.user.setPresence('online');
|
||||||
client.user.setActivity(Config.getconfig().NowPlaying);
|
client.user.setActivity(Config.getconfig().NowPlaying);
|
||||||
@@ -130,14 +128,14 @@ client.on('guildDelete', async (guild) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on("guildMemberAdd", async member => {
|
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");
|
let role = member.guild.roles.find(r => r.name === "Regular Joe");
|
||||||
if (!role) {
|
if (!role) {
|
||||||
Logger.log("role not found")
|
Logger.log("role not found")
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if(member.bot) return;
|
if (member.bot) return;
|
||||||
if(member.roles.find(r => r.name === "Regular Joe")) return Logger.warn("User already has role!");
|
if (member.roles.find(r => r.name === "Regular Joe")) return Logger.warn("User already has role!");
|
||||||
member.addRole(role)
|
member.addRole(role)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user