mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Open Role, Add Role, Remove Role
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[
|
||||
"inviteGuard",
|
||||
"modLog",
|
||||
"memberLog",
|
||||
"joinMsg",
|
||||
"leaveMsg",
|
||||
"staffRole",
|
||||
"singleRole",
|
||||
"openRoles"
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class AddRoleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'add-role',
|
||||
group: 'settings',
|
||||
memberName: 'add-role',
|
||||
description: 'Joins you to one of the open roles.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'Which role would you like to add?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { role } = args;
|
||||
const roles = msg.guild.settings.get('openRoles');
|
||||
if (!roles) return msg.say('No Roles are open to join.');
|
||||
if (!roles.has(role.id)) return msg.say('This role is not open.');
|
||||
msg.member.addRole(role);
|
||||
return msg.say(`You have been given the ${role.name} role.`);
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const settings = require('../../assets/json/clearsetting');
|
||||
|
||||
module.exports = class ClearSettingCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -11,11 +12,11 @@ module.exports = class ClearSettingCommand extends Command {
|
||||
args: [
|
||||
{
|
||||
key: 'setting',
|
||||
prompt: 'What setting do you want to clear? `inviteGuard`, `modLog`, `memberLog`, `joinMsg`, `leaveMsg`, `staffRole`, or `singleRole`?',
|
||||
prompt: 'What setting do you want to clear?',
|
||||
type: 'string',
|
||||
validate: setting => {
|
||||
if (['inviteGuard', 'modLog', 'memberLog', 'joinMsg', 'leaveMsg', 'staffRole', 'singleRole'].includes(setting)) return true;
|
||||
return 'Please enter either `inviteGuard`, `modLog`, `memberLog`, `joinMsg`, `leaveMsg`, `staffRole`, or `singleRole`.';
|
||||
if (settings.includes(setting)) return true;
|
||||
return `Please enter one of the following: ${settings.join(', ')}.`;
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class OpenRolesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'open-roles',
|
||||
group: 'settings',
|
||||
memberName: 'open-roles',
|
||||
description: 'Lets you add or remove roles open for anyone to join.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'action',
|
||||
prompt: 'Would you like to `add` or `remove` the role?',
|
||||
type: 'string',
|
||||
validate: action => {
|
||||
if (['add', 'remove'].includes(action.toLowerCase())) return true;
|
||||
return 'Please enter either `add` or `remove`.';
|
||||
},
|
||||
parse: action => action.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'Which role would you like to add/remove?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('ADMINISTRATOR');
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { action, role } = args;
|
||||
const roles = msg.guild.settings.get('openRoles', new Set());
|
||||
if (action === 'add') {
|
||||
if (roles.size > 5) return msg.say('Only 5 roles may be open.');
|
||||
if (roles.has(role.id)) return msg.say(`${role.name} is already set to open.`);
|
||||
roles.add(role.id);
|
||||
msg.guild.settings.set('openRoles', roles);
|
||||
return msg.say(`${role.name} has been added to the open roles.`);
|
||||
} else if (action === 'remove') {
|
||||
if (!roles.has(role.id)) return msg.say(`${role.name} is not set to open.`);
|
||||
roles.delete(role.id);
|
||||
msg.guild.settings.set('openRoles', roles);
|
||||
return msg.say(`${role.name} has been remove from the open roles.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class RemoveRoleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'remove-role',
|
||||
group: 'settings',
|
||||
memberName: 'remove-role',
|
||||
description: 'Removes you from one of the open roles.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'role',
|
||||
prompt: 'Which role would you like to remove?',
|
||||
type: 'role'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { role } = args;
|
||||
const roles = msg.guild.settings.get('openRoles');
|
||||
if (!roles) return msg.say('No Roles are open to join.');
|
||||
if (!roles.has(role.id)) return msg.say('This role is not open.');
|
||||
msg.member.removeRole(role);
|
||||
return msg.say(`You have been removed from the ${role.name} role.`);
|
||||
}
|
||||
};
|
||||
@@ -26,6 +26,7 @@ module.exports = class SettingListCommand extends Command {
|
||||
**Join Message:** ${msg.guild.settings.get('joinMsg', 'Welcome <user>! (Default)')}
|
||||
**Leave Message:** ${msg.guild.settings.get('leaveMsg', 'Bye <user>... (Default)')}
|
||||
**Single Role:** ${singleRole ? (msg.guild.roles.has(singleRole) ? msg.guild.roles.get(singleRole).name : 'Missing') : 'None'}
|
||||
**Open Roles:** ${msg.guild.settings.get('openRoles').size}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "19.10.2",
|
||||
"version": "19.11.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user