Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- });
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let prefix = botconfig.prefix;
- let messageArray = message.content.split(" ");
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- if(cmd === `${prefix}ticket`){
- const reason = message.content.split(" ").slice(1).join(" ");
- await message.react('👍')
- if (!message.guild.roles.exists("name", "Public Relations")) return message.channel.send(`This server doesn't have a \`Relations Employee\` 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.id)) return message.channel.send(`You already have a ticket open.`);
- message.guild.createChannel(`ticket-${message.author.id}`, "text").then(c => {
- let role = message.guild.roles.find("name", "Public Relations");
- 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(`:white_check_mark: Your ticket has been created, #${c.name}.`);
- const embed = new Discord.RichEmbed()
- .setColor(0xCF40FA)
- .addField(`Greetings! ${message.author.username}!`, `Please explain any inquiries, questions, and concerns on why you've opened this ticket with as much details as possible. Our **Public Relations Officers** will respond when they're available. Thank you! If no one responds within 4 hours, feel free to tag them.`)
- .setTimestamp();
- c.send({
- embed: embed
- });
- }).catch(console.error); // Send errors to console
- }
- // Close ticket command
- if(cmd === `${prefix}close`){
- if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
- // Confirm delete - with timeout (Not command)
- message.channel.send(`Are you sure? Once confirmed, you cannot reverse this action!\nTo confirm, type \`/confirm\`. This will time out in 10 seconds and be cancelled.`)
- .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