Merge pull request #230 from lbryio/Coolguy3289-patch-2

Add catch for DMs, @nikooo777 could you update the running version?
This commit is contained in:
filipnyquist 2019-02-20 08:20:43 +01:00 committed by GitHub
commit b6c9a2dd11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
let config = require('config');
let botconfig = config.get('bot');
let rolelist = config.get('rolelist');
let inPrivate = require('../helpers.js').inPrivate;
exports.commands = [
'addrole', // command that is in this file, every command needs it own export as shown below
@ -17,6 +18,10 @@ exports.addrole = {
let newrole = msg.guild.roles.find('name', suffix);
let baserole = msg.guild.roles.find('name', rolelist.baserole);
// Checks if the user put a role in the message.
if (inPrivate(msg)) {
msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.');
return;
} else {
if (suffix) {
//suffix = suffix.toLowerCase();
// Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config.
@ -49,6 +54,7 @@ exports.addrole = {
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
}
}
}
};
exports.delrole = {
usage: '<role>',
@ -57,6 +63,10 @@ exports.delrole = {
// Here in the bot, msg and suffix are available, this function can be async if needed.
let oldrole = msg.guild.roles.find('name', suffix);
// Checks if the user put a role in the message.
if (inPrivate(msg)) {
msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.');
return;
} else {
if (suffix) {
// Checks if the role mentioned in the message is in the allowed roles listed in the Wunderbot config.
if (rolelist.allowedroles.includes(suffix)) {
@ -78,11 +88,16 @@ exports.delrole = {
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
}
}
}
};
exports.roles = {
usage: '',
description: 'displays roles you can give yourself',
process: function(bot, msg, suffix) {
if (inPrivate(msg)) {
msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.');
return;
} else {
// Here in the bot, msg and suffix are available, this function can be async if needed.
msg.channel.send({
embed: {
@ -119,6 +134,7 @@ exports.roles = {
});
//msg.channel.send(JSON.stringify(rolelist.allowedroles));
}
}
};
function buildRoleString(roles) {