2019-08-12 08:48:14 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-11-27 12:16:30 +01:00
|
|
|
const joinChannel = require('../../models').joinChannel;
|
2019-08-12 08:48:14 +02:00
|
|
|
const rand = require('../../rand.js');
|
|
|
|
|
|
|
|
class fakejoinCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('fakejoin', {
|
|
|
|
aliases: ['fakejoin'],
|
|
|
|
category: 'admin',
|
|
|
|
channelRestriction: 'guild',
|
2019-11-22 20:56:54 +01:00
|
|
|
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
2019-08-12 08:48:14 +02:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'member',
|
|
|
|
type: 'string',
|
|
|
|
match: 'rest'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Fake join message',
|
|
|
|
usage: '[text]',
|
|
|
|
examples: ['Supositware']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2019-11-27 12:16:30 +01:00
|
|
|
const join = await joinChannel.findOne({where: {guildID: message.guild.id}});
|
2019-08-12 08:48:14 +02:00
|
|
|
|
2019-11-27 12:16:30 +01:00
|
|
|
if (join) {
|
|
|
|
const channel = this.client.channels.get(join.get('channelID'));
|
2019-08-12 08:48:14 +02:00
|
|
|
|
2019-11-27 12:16:30 +01:00
|
|
|
let welcomeMessage = join.get('message');
|
2019-08-12 08:48:14 +02:00
|
|
|
|
2019-11-27 12:16:30 +01:00
|
|
|
welcomeMessage = welcomeMessage.replace(/\[member\]/, args.member);
|
|
|
|
welcomeMessage = welcomeMessage.replace(/\[server\]/, message.guild.name);
|
|
|
|
|
2019-08-12 08:48:14 +02:00
|
|
|
let attach;
|
2019-11-27 12:16:30 +01:00
|
|
|
if (welcomeMessage.includes('[attach:')) {
|
|
|
|
attach = welcomeMessage.split(/(\[attach:.*?])/);
|
2019-08-12 08:48:14 +02:00
|
|
|
for (let i = 0, l = attach.length; i < l; i++) {
|
|
|
|
if (attach[i].includes('[attach:')) {
|
|
|
|
attach = attach[i].replace('[attach:', '').slice(0, -1);
|
|
|
|
i = attach.length;
|
|
|
|
}
|
|
|
|
}
|
2019-11-27 12:16:30 +01:00
|
|
|
welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, '');
|
2019-08-12 08:48:14 +02:00
|
|
|
}
|
2019-11-27 12:16:30 +01:00
|
|
|
|
|
|
|
welcomeMessage = rand.random(welcomeMessage);
|
|
|
|
|
2019-08-12 08:48:14 +02:00
|
|
|
message.delete();
|
|
|
|
if (attach) {
|
2019-11-27 12:16:30 +01:00
|
|
|
return channel.send(welcomeMessage, {files: [attach]});
|
2019-08-12 08:48:14 +02:00
|
|
|
} else {
|
2019-11-27 12:16:30 +01:00
|
|
|
return channel.send(welcomeMessage);
|
2019-08-12 08:48:14 +02:00
|
|
|
}
|
|
|
|
} else {
|
2019-11-27 12:16:30 +01:00
|
|
|
return message.channel.send('Are you sure this server have a join message?');
|
2019-08-12 08:48:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = fakejoinCommand;
|