2019-05-04 18:09:05 +03:00
|
|
|
const Discord = require('discord.js');
|
|
|
|
const config = require('../config.json');
|
2019-05-06 19:18:43 +03:00
|
|
|
const log = require(`leekslazylogger`);
|
2019-05-04 18:09:05 +03:00
|
|
|
module.exports = {
|
|
|
|
name: 'add',
|
|
|
|
description: 'Add a member to a ticket channel',
|
|
|
|
usage: '<@member>',
|
|
|
|
aliases: ['adduser'],
|
|
|
|
example: 'add @exampleUser',
|
2019-05-05 22:19:29 +03:00
|
|
|
args: true,
|
2019-05-04 18:09:05 +03:00
|
|
|
cooldown: config.cooldown,
|
|
|
|
guildOnly: true,
|
|
|
|
execute(message, args) {
|
|
|
|
const client = message.client;
|
|
|
|
// command starts here
|
|
|
|
message.delete();
|
2019-05-05 22:19:29 +03:00
|
|
|
if(!message.channel.name.startsWith('ticket-')) {
|
|
|
|
if(config.useEmbeds) {
|
|
|
|
const notTicket = new Discord.RichEmbed()
|
|
|
|
.setColor("#E74C3C")
|
|
|
|
.setDescription(`:x: **This command can only be used within a ticket channel**`)
|
|
|
|
return message.channel.send(notTicket);
|
|
|
|
} else {
|
|
|
|
return message.channel.send(`:x: **This command can only be used within a ticket channel**`)
|
|
|
|
}
|
|
|
|
}
|
2019-05-04 18:09:05 +03:00
|
|
|
|
2019-05-05 22:19:29 +03:00
|
|
|
let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
|
|
|
|
if(!user) {
|
|
|
|
if(config.useEmbeds) {
|
|
|
|
const err1 = new Discord.RichEmbed()
|
|
|
|
.setColor("#E74C3C")
|
|
|
|
.setDescription(`:x: **Unknown user.** Please mention a valid user.`)
|
|
|
|
return message.channel.send(err1);
|
|
|
|
} else {
|
|
|
|
return message.channel.send(`:x: **Unknown user.** Please mention a valid user.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
message.channel.overwritePermissions(user, {
|
|
|
|
SEND_MESSAGES: true,
|
|
|
|
READ_MESSAGES: true,
|
|
|
|
ATTACH_FILES: true
|
|
|
|
});
|
|
|
|
if(config.useEmbeds) {
|
|
|
|
const added = new Discord.RichEmbed()
|
|
|
|
.setColor(config.colour)
|
|
|
|
.setDescription(`${user} has been added.`)
|
|
|
|
message.channel.send(added);
|
|
|
|
} else {
|
|
|
|
message.channel.send(`${user} has been added.`);
|
|
|
|
}
|
|
|
|
// log
|
|
|
|
if(config.useEmbeds) {
|
|
|
|
const embed = new Discord.RichEmbed()
|
|
|
|
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
|
|
|
|
.setTitle("User Added")
|
|
|
|
.setColor(config.colour)
|
|
|
|
.addField("Username", user, true)
|
|
|
|
.addField("Added by", message.author, true)
|
|
|
|
.addField("Channel", message.channel, true)
|
|
|
|
.setFooter(`DiscordTickets`)
|
|
|
|
.setTimestamp();
|
|
|
|
client.channels.get(config.logChannel).send({embed})
|
|
|
|
} else {
|
|
|
|
client.channels.get(config.logChannel).send(`User added to a ticket by **${message.author.tag} (${message.author.id})**`);
|
|
|
|
}
|
|
|
|
log.info(`${message.author.tag} added a user to a ticket (#${message.channel})`)
|
|
|
|
} catch(error) {
|
|
|
|
log.error(error);
|
|
|
|
}
|
2019-05-04 18:09:05 +03:00
|
|
|
|
|
|
|
// command ends here
|
|
|
|
},
|
|
|
|
};
|