mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-09-02 02:05:17 +00:00
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:
commit
b6c9a2dd11
1 changed files with 83 additions and 67 deletions
|
@ -1,6 +1,7 @@
|
||||||
let config = require('config');
|
let config = require('config');
|
||||||
let botconfig = config.get('bot');
|
let botconfig = config.get('bot');
|
||||||
let rolelist = config.get('rolelist');
|
let rolelist = config.get('rolelist');
|
||||||
|
let inPrivate = require('../helpers.js').inPrivate;
|
||||||
|
|
||||||
exports.commands = [
|
exports.commands = [
|
||||||
'addrole', // command that is in this file, every command needs it own export as shown below
|
'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 newrole = msg.guild.roles.find('name', suffix);
|
||||||
let baserole = msg.guild.roles.find('name', rolelist.baserole);
|
let baserole = msg.guild.roles.find('name', rolelist.baserole);
|
||||||
// Checks if the user put a role in the message.
|
// 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) {
|
if (suffix) {
|
||||||
//suffix = suffix.toLowerCase();
|
//suffix = suffix.toLowerCase();
|
||||||
// Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config.
|
// 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!');
|
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
exports.delrole = {
|
exports.delrole = {
|
||||||
usage: '<role>',
|
usage: '<role>',
|
||||||
|
@ -57,6 +63,10 @@ exports.delrole = {
|
||||||
// Here in the bot, msg and suffix are available, this function can be async if needed.
|
// Here in the bot, msg and suffix are available, this function can be async if needed.
|
||||||
let oldrole = msg.guild.roles.find('name', suffix);
|
let oldrole = msg.guild.roles.find('name', suffix);
|
||||||
// Checks if the user put a role in the message.
|
// 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) {
|
if (suffix) {
|
||||||
// Checks if the role mentioned in the message is in the allowed roles listed in the Wunderbot config.
|
// Checks if the role mentioned in the message is in the allowed roles listed in the Wunderbot config.
|
||||||
if (rolelist.allowedroles.includes(suffix)) {
|
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!');
|
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
exports.roles = {
|
exports.roles = {
|
||||||
usage: '',
|
usage: '',
|
||||||
description: 'displays roles you can give yourself',
|
description: 'displays roles you can give yourself',
|
||||||
process: function(bot, msg, suffix) {
|
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.
|
// Here in the bot, msg and suffix are available, this function can be async if needed.
|
||||||
msg.channel.send({
|
msg.channel.send({
|
||||||
embed: {
|
embed: {
|
||||||
|
@ -119,6 +134,7 @@ exports.roles = {
|
||||||
});
|
});
|
||||||
//msg.channel.send(JSON.stringify(rolelist.allowedroles));
|
//msg.channel.send(JSON.stringify(rolelist.allowedroles));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildRoleString(roles) {
|
function buildRoleString(roles) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue