mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Custom Settings
This commit is contained in:
+35
-4
@@ -52,16 +52,47 @@ client.on('warn', console.warn);
|
||||
|
||||
client.on('commandError', (command, err) => console.error(command.name, err));
|
||||
|
||||
client.on('message', (msg) => {
|
||||
if (!msg.guild) return;
|
||||
if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return;
|
||||
const topic = msg.guild.defaultChannel.topic || '';
|
||||
if (!topic.includes('<inviteguard>')) return;
|
||||
if (msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) msg.delete();
|
||||
msg.reply('Invites are prohibited from being posted here.');
|
||||
});
|
||||
|
||||
client.on('guildMemberAdd', (member) => {
|
||||
const channel = member.guild.channels.find('name', 'member-log');
|
||||
const channel = member.guild.channels.filter((channel) => {
|
||||
const topic = channel.topic || '';
|
||||
if (topic.includes('<memberlog>')) return true;
|
||||
}).first() || member.guild.channels.find('name', 'member-log');
|
||||
if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
channel.send(`Welcome ${member.user.username}!`);
|
||||
const parseMsg = (topic) => {
|
||||
if (!topic || !topic.includes('<joinmessage:')) return '';
|
||||
return topic.split('<joinmessage:').join('').split('>')[0]
|
||||
.replace(/(\(member\))/gi, member.user.username)
|
||||
.replace(/(\(server\))/gi, member.guild.name)
|
||||
.replace(/(\(mention\))/gi, member.toString());
|
||||
};
|
||||
const msg = channel.topic ? parseMsg(channel.topic) : '';
|
||||
channel.send(msg || `Welcome ${member.user.username}!`);
|
||||
});
|
||||
|
||||
client.on('guildMemberRemove', (member) => {
|
||||
const channel = member.guild.channels.find('name', 'member-log');
|
||||
const channel = member.guild.channels.filter((channel) => {
|
||||
const topic = channel.topic || '';
|
||||
if (topic.includes('<memberlog>')) return true;
|
||||
}).first() || member.guild.channels.find('name', 'member-log');
|
||||
if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
|
||||
channel.send(`Bye ${member.user.username}...`);
|
||||
const parseMsg = (topic) => {
|
||||
if (!topic || !topic.includes('<leavemessage:')) return '';
|
||||
return topic.split('<leavemessage:').join('').split('>')[0]
|
||||
.replace(/(\(member\))/gi, member.user.username)
|
||||
.replace(/(\(server\))/gi, member.guild.name)
|
||||
.replace(/(\(mention\))/gi, member.toString());
|
||||
};
|
||||
const msg = channel.topic ? parseMsg(channel.topic) : '';
|
||||
channel.send(msg || `Bye ${member.user.username}...`);
|
||||
});
|
||||
|
||||
client.on('guildCreate', async (guild) => {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "25.0.2",
|
||||
"version": "25.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user