mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 02:45:22 +02:00
This is better
This commit is contained in:
@@ -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')}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user