This is better

This commit is contained in:
Daniel Odendahl Jr
2018-02-06 23:55:40 +00:00
parent 901c053efa
commit d265b35857
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
const roles = HOME_GUILD_ROLES.split(',');
module.exports = class RoleListCommand extends Command {
constructor(client) {
@@ -19,7 +20,7 @@ module.exports = class RoleListCommand extends Command {
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
return msg.say(stripIndents`
**Roles available in ${msg.guild.name}**:
${msg.guild.roles.filter(role => HOME_GUILD_ROLES.split(',').includes(role.id)).map(role => role.name).join('\n')}
${msg.guild.roles.filter(role => roles.includes(role.id)).map(role => role.name).join('\n')}
`);
}
};
+2 -1
View File
@@ -1,5 +1,6 @@
const { Command } = require('discord.js-commando');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
const roles = HOME_GUILD_ROLES.split(',');
module.exports = class SubscribeCommand extends Command {
constructor(client) {
@@ -24,7 +25,7 @@ module.exports = class SubscribeCommand extends Command {
async run(msg, { role }) {
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
if (!HOME_GUILD_ROLES.split(',').includes(role.id)) return msg.reply('This role is not open!');
if (!roles.includes(role.id)) return msg.reply('This role is not open!');
if (!role.editable) return msg.reply('I do not have permission to manage this role!');
if (msg.member.roles.has(role.id)) return msg.reply('You are already a member of this role!');
await msg.member.roles.add(role);
+2 -1
View File
@@ -1,5 +1,6 @@
const { Command } = require('discord.js-commando');
const { HOME_GUILD_ID, HOME_GUILD_ROLES } = process.env;
const roles = HOME_GUILD_ROLES.split(',');
module.exports = class UnsubscribeCommand extends Command {
constructor(client) {
@@ -24,7 +25,7 @@ module.exports = class UnsubscribeCommand extends Command {
async run(msg, { role }) {
if (msg.guild.id !== HOME_GUILD_ID) return msg.reply('This command only works in the home server.');
if (!HOME_GUILD_ROLES.split(',').includes(role.id)) return msg.reply('This role is not open!');
if (!roles.includes(role.id)) return msg.reply('This role is not open!');
if (!role.editable) return msg.reply('I do not have permission to manage this role!');
if (!msg.member.roles.has(role.id)) return msg.reply('You are not a member of this role!');
await msg.member.roles.remove(role);