Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on("message", (message) => {
- if (message.content.startsWith("$ticket")) {
- if(message.author.id == bannedMembers) return message.channel.send('**Sorry, but You have been banned, so you can\'t use this commmand**').then(msg => {msg.delete(5000)});
- if(message.author.bot) return;
- if(message.channel.type == "dm") return;
- if (!message.guild.roles.exists("name", "Support Team")) return message.channel.send(`I can't find **Support Team** Role`);
- let reason = message.content.split(" ").slice(1).join(" ");
- if(reason !== null){
- y = `${reason}`;
- }else{
- y = "No Reason";
- }
- if (message.guild.channels.exists("name", `ticket-${message.author.username}`)) return message.channel.send(`You have already created a ticket`);
- message.guild.createChannel(`ticket-${message.author.username}`, "text").then(c => {
- let role = message.guild.roles.find("name", "Support Team");
- let role2 = message.guild.roles.find("name", "@everyone");
- c.overwritePermissions(role, {
- SEND_MESSAGES: true,
- READ_MESSAGES: true
- });
- c.overwritePermissions(role2, {
- SEND_MESSAGES: false,
- READ_MESSAGES: false
- });
- c.overwritePermissions(message.author, {
- SEND_MESSAGES: true,
- READ_MESSAGES: true
- });
- message.channel.send(`${message.author.username}, Done Your Ticket has been Created <#${c.id}>`);
- const embed = new Discord.RichEmbed()
- .setColor(0xCF40FA)
- .addField('User: ',`[ ${message.author.username} ]`,true)
- .addField('\nUserID: ', `[ ${message.author.id} ]`, true)
- .addField('\nCMD writed in Channel', `#${message.channel.name}`, true)
- .addField('\nReason: ', `[ ${reason} ]`)
- .setFooter(message.guild.name,message.guild.avatarURL)
- .setTimestamp();
- c.send({
- embed: embed
- });
- }).catch(console.error);
- }
- if (message.content.startsWith("$close")) {
- if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
- message.channel.send(`Are you sure? You have 10 seconds to delete the channel type **$confirm** to confirm.`)
- .then((m) => {
- message.channel.awaitMessages(response => response.content == '$confirm', {
- max: 1,
- time: 10000,
- errors: ['time'],
- })
- .then((collected) => {
- message.channel.delete();
- })
- .catch(() => {
- m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
- m2.delete();
- }, 3000);
- });
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement