You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/commands/fun/fakejoin.js

64 lines
1.6 KiB
JavaScript

5 years ago
const { Command } = require('discord-akairo');
const joinChannel = require('../../models').joinChannel;
5 years ago
const rand = require('../../rand.js');
class fakejoinCommand extends Command {
constructor() {
super('fakejoin', {
aliases: ['fakejoin'],
category: 'admin',
channelRestriction: 'guild',
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
5 years ago
args: [
{
id: 'member',
type: 'string',
match: 'rest'
}
],
description: {
content: 'Fake join message',
usage: '[text]',
examples: ['Supositware']
}
});
}
async exec(message, args) {
const join = await joinChannel.findOne({where: {guildID: message.guild.id}});
5 years ago
if (join) {
const channel = this.client.channels.get(join.get('channelID'));
5 years ago
let welcomeMessage = join.get('message');
5 years ago
welcomeMessage = welcomeMessage.replace(/\[member\]/, args.member);
welcomeMessage = welcomeMessage.replace(/\[server\]/, message.guild.name);
5 years ago
let attach;
if (welcomeMessage.includes('[attach:')) {
attach = welcomeMessage.split(/(\[attach:.*?])/);
5 years ago
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;
}
}
welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, '');
5 years ago
}
welcomeMessage = rand.random(welcomeMessage);
5 years ago
message.delete();
if (attach) {
return channel.send(welcomeMessage, {files: [attach]});
5 years ago
} else {
return channel.send(welcomeMessage);
5 years ago
}
} else {
return message.channel.send('Are you sure this server have a join message?');
5 years ago
}
}
}
module.exports = fakejoinCommand;