Custom Settings

This commit is contained in:
Daniel Odendahl Jr
2017-06-24 16:33:59 +00:00
parent 23e2cc6dfd
commit 181da1a186
2 changed files with 36 additions and 5 deletions
+35 -4
View File
@@ -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
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "25.0.2",
"version": "25.1.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {