mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Settings for modLog and memberLog
This commit is contained in:
@@ -37,9 +37,9 @@ module.exports = class BanCommand extends Command {
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||
return message.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
const modlogs = message.guild.channels.find('name', message.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -34,9 +34,9 @@ module.exports = class KickCommand extends Command {
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
|
||||
return message.say('This Command requires the `Kick Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
const modlogs = message.guild.channels.find('name', message.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -41,9 +41,9 @@ module.exports = class UnbanCommand extends Command {
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||
return message.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
const modlogs = message.guild.channels.find('name', message.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { memberID, reason } = args;
|
||||
|
||||
@@ -31,9 +31,9 @@ module.exports = class WarnCommand extends Command {
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
const modlogs = message.guild.channels.find('name', message.guild.settings.get('modLog', 'mod_logs'));
|
||||
if (!modlogs)
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
|
||||
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class MemberLogCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'memberchannel',
|
||||
group: 'util',
|
||||
memberName: 'memberchannel',
|
||||
description: 'Sets the channel for the member logs to be sent.',
|
||||
guildOnly: true,
|
||||
args: [{
|
||||
key: 'channel',
|
||||
prompt: 'What is the channel you want to send logs to?',
|
||||
type: 'channel'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.permissions.has('ADMINISTRATOR');
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
const { channel } = args;
|
||||
return message.guild.settings.set('memberLog', channel.name);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class ModChannelCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'modchannel',
|
||||
group: 'util',
|
||||
memberName: 'modchannel',
|
||||
description: 'Sets the channel for the mod logs to be sent.',
|
||||
guildOnly: true,
|
||||
args: [{
|
||||
key: 'channel',
|
||||
prompt: 'What is the channel you want to send logs to?',
|
||||
type: 'channel'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return msg.member.permissions.has('ADMINISTRATOR');
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
const { channel } = args;
|
||||
return message.guild.settings.set('modLog', channel.name);
|
||||
}
|
||||
};
|
||||
@@ -35,14 +35,14 @@ client.registry
|
||||
.registerCommandsIn(path.join(__dirname, 'commands'));
|
||||
|
||||
client.on('guildMemberAdd', (member) => {
|
||||
const channel = member.guild.channels.find('name', 'member_logs');
|
||||
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
|
||||
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_logs');
|
||||
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
|
||||
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": "16.1.0",
|
||||
"version": "16.2.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -20,4 +20,4 @@ class Database {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Database;
|
||||
module.exports = Database;
|
||||
|
||||
Reference in New Issue
Block a user