Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on("message", (message) => {
- if (message.content.startsWith("-new")) {
- const reason = message.content.split(" ").slice(1).join(" ");
- if (!message.guild.roles.exists("name", "Support Team")) return message.channel.send(`This server doesn't have a \`Support Team\` role made, so the ticket won't be opened.\nIf you are an administrator, make one with that name exactly and give it to users that should be able to see tickets.`);
- if (message.guild.channels.exists("name", "ticket-${message.author.username}" + message.author.username)) return message.channel.send(`You already have a ticket open.`);
- 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
- });
- const ticketnew = new Discord.RichEmbed()
- .setColor("RANDOM")
- .addField(`| :white_check_mark: **Your ticket was created** ،`, `**#${c.name}.**`)
- .setAuthor(`${message.author.tag}`, message.author.avatarURL)
- .setFooter(client.user.username , client.user.avatarURL)
- .setTimestamp();
- message.channel.send(ticketnew);
- const embed = new Discord.RichEmbed()
- .setColor(0xCF40FA)
- .addField(`Hello ${message.author.username}!`, `Please try to explain why this ticket is opened as closely as possible. Our support team will soon be of help.`)
- .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? After confirmation, you can not reverse this action!\n Type ، For confirmation\`-confirm\`. This will lead to a time-out within 10 seconds and cancel`)
- .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