Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const config = require('../../config.json');
- const randomString = require('random-string');
- module.exports.run = async (bot, message, args) => {
- // ID van de categorie van de tickets.
- const categoryId = "691192396276432946";
- const client = message.client;
- // command starts here
- message.delete();
- let topic = args.join(" ");
- let nums = randomString({
- length: 3,
- numeric: true,
- letters: false,
- special: false,
- });
- let num = randomString({
- length: 3,
- numeric: true,
- letters: false,
- special: false,
- });
- let id = nums.toString().substr(0, 3) + num;
- let chan = `ticket♯${id}`;
- if (message.guild.channels.cache.find(x => x.name === chan)) {
- if (config.useEmbeds) {
- const err1 = new Discord.MessageEmbed()
- .setColor("#E74C3C")
- .setDescription(`:x: You already have an open ticket.`)
- return message.channel.send(err1)
- } else {
- message.channel.send(`:x: You already have an open ticket.`)
- }
- };
- message.guild.channels.create(`ticket♯${id}`, {
- type: 'text'
- }).then(async c => {
- c.setParent(categoryId);
- c.overwritePermissions(message.guild.defaultRole, {
- VIEW_CHANNEL: false,
- SEND_MESSAGES: false
- })
- c.overwritePermissions(message.member, {
- VIEW_CHANNEL: true,
- SEND_MESSAGES: true
- })
- c.setTopic(`${message.author} | ${topic}`);
- if (config.tagHereOnly) {
- await c.send(`${message.author}, a user has created a new ticket.\n`);
- };
- if (config.ticketImage) {
- var embedCreateTicket = new Discord.MessageEmbed()
- .setAuthor('Master [Code-Docs] Support Server', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
- //.setAuthor(`Ticket♯${id}` , 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
- .setColor("#1f264d")
- .setTitle(`Ticket♯${id}`)
- .setDescription(`yout ticket has been created with [Ticket♯${id}]`, topic)
- .setFooter("Your ticket has been created Succesfully!!!!")
- .setTimestamp()
- c.send(embedCreateTicket)({
- files: [`../image.png`]
- })
- } else {
- var embedCreateTicket = new Discord.MessageEmbed()
- .setAuthor('Master [Code-Docs] Support Server', 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
- //.setAuthor(`Ticket♯${id}` , 'https://thumbs.gfycat.com/DeliciousJoyfulAustralianshelduck-max-1mb.gif')
- .setColor("#1f264d")
- .setTitle(`Ticket♯${id}`)
- .addField(`yout ticket has been created with [Ticket♯${id}]`, topic)
- .setFooter("Your ticket has been created Succesfully!!!!")
- .setTimestamp()
- c.send(embedCreateTicket)
- }
- const created = new Discord.MessageEmbed()
- .setColor("#1f264d")
- .setDescription(`Your ticket **Ticket♯${id}** has been created.\nPlease read the information sent and follow any instructions given.`)
- .setTimestamp();
- message.channel.send(created).then(message => message.delete(2000));
- message.delete()
- // const welcome = new Discord.MessageEmbed()
- // .setColor("#1f264d")
- // .setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
- // message.channel.send(welcome);
- // if (config.useEmbeds) {
- // message.channel.send(created)
- // let w = await channel.send(welcome);
- // } else {
- // message.channel.send(`Your ticket (Ticket♯${id}) has been created.\nPlease read the information sent and follow any instructions given.`)
- // let c = await channel.send(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`);
- // }
- })
- }
- module.exports.config = {
- name: "ticket-create-2",
- description: 'Create a new ticket',
- usage: '<brief description>',
- aliases: ["new"],
- example: 'new I found an error',
- accessableby: "Members",
- args: true,
- guildOnly: true,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement