mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 08:19:08 +02:00
ID-Based Guild Settings
This commit is contained in:
@@ -35,15 +35,15 @@ module.exports = class BanCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||
return msg.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = msg.guild.channels.find('name', msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
|
||||
if (!modlogs)
|
||||
return msg.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -32,15 +32,15 @@ module.exports = class KickCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
|
||||
return msg.say('This Command requires the `Kick Members` Permission.');
|
||||
const modlogs = msg.guild.channels.find('name', msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
|
||||
if (!modlogs)
|
||||
return msg.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = class PruneCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('MANAGE_MESSAGES') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('MANAGE_MESSAGES') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class SoftbanCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
@@ -40,9 +40,9 @@ module.exports = class SoftbanCommand extends Command {
|
||||
return msg.say('This Command requires the `Ban Members` Permission.');
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
|
||||
return msg.say('This Command requires the `Kick Members` Permission.');
|
||||
const modlogs = msg.guild.channels.find('name', msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
|
||||
if (!modlogs)
|
||||
return msg.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -39,15 +39,15 @@ module.exports = class UnbanCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||
return msg.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = msg.guild.channels.find('name', msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return msg.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { id, reason } = args;
|
||||
|
||||
@@ -31,13 +31,13 @@ module.exports = class WarnCommand extends Command {
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.exists('name', msg.guild.settings.get('staffRole', 'Server Staff'));
|
||||
return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole'));
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const modlogs = msg.guild.channels.find('name', msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return msg.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
return msg.say('This Command requires a channel set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = class MemberLogCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const { channel } = args;
|
||||
msg.guild.settings.set('memberLog', channel.name);
|
||||
msg.guild.settings.set('memberLog', channel.id);
|
||||
return msg.say(`Member Log channel set to ${channel.name}.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = class ModChannelCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const { channel } = args;
|
||||
msg.guild.settings.set('modLog', channel.name);
|
||||
msg.guild.settings.set('modLog', channel.id);
|
||||
return msg.say(`Mod Log channel set to ${channel.name}.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = class StaffRoleCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const { role } = args;
|
||||
msg.guild.settings.set('staffRole', role.name);
|
||||
msg.guild.settings.set('staffRole', role.id);
|
||||
return msg.say(`Server Staff role set to ${role.name}.`);
|
||||
}
|
||||
};
|
||||
|
||||
+3
-2
@@ -11,8 +11,9 @@
|
||||
<div class="xiaobox">
|
||||
<h2>Notes:</h2>
|
||||
<ol>
|
||||
<li>Moderation Commands Require a Channel Named "mod_logs" to send Ban/Kick/Unban/Warn Logs, or you can set a channel with x;modchannel</li>
|
||||
<li>To use Member Join/Leave Logging, make a channel named "member_logs", or set a channel with x;memberchannel</li>
|
||||
<li>Moderation Commands Require a Channel set with x;modchannel to send Ban/Kick/Unban/Warn Logs</li>
|
||||
<li>To use Member Join/Leave Logging, set a channel with x;memberchannel</li>
|
||||
<li>You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole</li>
|
||||
<li>Use x;help to View a Command List</li>
|
||||
<li>Visit my <a href="https://discord.gg/fqQF8mc">Home Server</a> for more support, or for updates, or if you just want to hang out.</li>
|
||||
</ol>
|
||||
|
||||
@@ -57,8 +57,9 @@
|
||||
<div class="xiaobox">
|
||||
<h2>Notes:</h2>
|
||||
<ol>
|
||||
<li>Moderation Commands Require a Channel Named "mod_logs" to send Ban/Kick/Unban/Warn Logs, or you can set a channel with x;modchannel</li>
|
||||
<li>To use Member Join/Leave Logging, make a channel named "member_logs", or set a channel with x;memberchannel</li>
|
||||
<li>Moderation Commands Require a Channel set with x;modchannel to send Ban/Kick/Unban/Warn Logs</li>
|
||||
<li>To use Member Join/Leave Logging, set a channel with x;memberchannel</li>
|
||||
<li>You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole</li>
|
||||
<li>Use x;help to View a Command List</li>
|
||||
<li>Visit my <a href="https://discord.gg/fqQF8mc">Home Server</a> for more support, or for updates, or if you just want to hang out.</li>
|
||||
</ol>
|
||||
|
||||
@@ -38,14 +38,14 @@ client.registry
|
||||
.registerCommandsIn(path.join(__dirname, 'commands'));
|
||||
|
||||
client.on('guildMemberAdd', (member) => {
|
||||
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
|
||||
const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
|
||||
if (!channel) return;
|
||||
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
channel.send(`Welcome ${member.user.username}!`);
|
||||
});
|
||||
|
||||
client.on('guildMemberRemove', (member) => {
|
||||
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
|
||||
const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
|
||||
if (!channel) return;
|
||||
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
channel.send(`Bye ${member.user.username}...`);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "17.2.12",
|
||||
"version": "18.0.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user