From d265b35857692a71b03839c60dea52ba2050483b Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 6 Feb 2018 23:55:40 +0000 Subject: [PATCH] This is better --- commands/role-manage/role-list.js | 3 ++- commands/role-manage/subscribe.js | 3 ++- commands/role-manage/unsubscribe.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/role-manage/role-list.js b/commands/role-manage/role-list.js index 18d92ed0..c0b1508c 100644 --- a/commands/role-manage/role-list.js +++ b/commands/role-manage/role-list.js @@ -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')} `); } }; diff --git a/commands/role-manage/subscribe.js b/commands/role-manage/subscribe.js index 80f4ec72..5421abda 100644 --- a/commands/role-manage/subscribe.js +++ b/commands/role-manage/subscribe.js @@ -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); diff --git a/commands/role-manage/unsubscribe.js b/commands/role-manage/unsubscribe.js index 9d50530d..b3389fb7 100644 --- a/commands/role-manage/unsubscribe.js +++ b/commands/role-manage/unsubscribe.js @@ -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);