Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bot.on('message', message => {
- if (isCommand(message, "new")) {
- const reason = message.content.split(" ").slice(1).join(" ");
- if (!message.guild.roles.exists("name", "Staff")) return message.channel.send(`This server doesn't have a \`Support Staff\` 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.username}`, { type: 'text' }).then(c => {
- let role = message.guild.roles.find(c => c.name === "Staff")
- let role2 = message.guild.roles.find(c => c.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(`Hey ${message.author.username}!`, `Please try explain why you opened this ticket with as much detail as possible. Our **Staff** will be here soon to help.`)
- .setTimestamp();
- c.send({
- embed: embed
- });
- }).catch(console.error); // Send errors to console
- }
- function isCommand(message)
- {
- return message.content.toLowerCase().startsWith(PREFIX);
- }
- function clean(text)
- {
- if (typeof(text) === "string")
- return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
- else
- return text;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement