fixed new.js

This commit is contained in:
Eartharoid 2019-10-22 22:29:30 +01:00
parent d4522cd729
commit 60044a1e70
2 changed files with 75 additions and 69 deletions

View File

@ -23,11 +23,11 @@ module.exports = {
// letters: false,
// special: false,
// });
let id = message.author.id.toString().substr(0,4) + message.author.discriminator;
let id = message.author.id.toString().substr(0, 4) + message.author.discriminator;
let chan = `ticket-${id}`;
if(message.guild.channels.some(channel => chan.includes(channel.name))) {
if(config.useEmbeds){
if (message.guild.channels.some(channel => chan.includes(channel.name))) {
if (config.useEmbeds) {
const err1 = new Discord.RichEmbed()
.setColor("#E74C3C")
.setDescription(`:x: You already have an open ticket.`)
@ -38,11 +38,13 @@ module.exports = {
};
message.guild.createChannel(`ticket-${id}`).then(async c => {
message.guild.createChannel(`ticket-${id}`, {
type: 'text'
}).then(async c => {
c.setParent(config.ticketsCat);
// let supportRole = message.guild.roles.find(`id`, config.supportRole)
let supportRole = message.guild.roles.get(config.supportRole)
if(!supportRole) return message.channel.send(":x: No **Support Team** role found.");
if (!supportRole) return message.channel.send(":x: No **Support Team** role found.");
c.overwritePermissions(message.guild.defaultRole, {
@ -58,14 +60,16 @@ module.exports = {
SEND_MESSAGES: true
})
c.setTopic(`${message.author} | ${topic}`);
if(config.tagHereOnly){
if (config.tagHereOnly) {
await c.send(`@here, a user has created a new ticket.\n`);
} else {
await c.send(`<@&${config.supportRole}>, a user has created a new ticket.\n`);
};
if(config.ticketImage) {
await c.send(`__**Here's your ticket channel, ${message.author}**__`,{files: [`./image.png`]})
if (config.ticketImage) {
await c.send(`__**Here's your ticket channel, ${message.author}**__`, {
files: [`./image.png`]
})
} else {
await c.send(`__**Here's your ticket channel, ${message.author}**__`)
}
@ -79,7 +83,7 @@ module.exports = {
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
if(config.useEmbeds) {
if (config.useEmbeds) {
message.channel.send(created)
let w = await c.send(welcome)
await w.pin();
@ -92,7 +96,7 @@ module.exports = {
}
// log
if(config.useEmbeds) {
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
.setTitle("New Ticket")
@ -102,7 +106,9 @@ module.exports = {
.addField("Channel", c, true)
.setFooter(`DiscordTickets`)
.setTimestamp();
client.channels.get(config.logChannel).send({embed})
client.channels.get(config.logChannel).send({
embed
})
} else {
client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
}

View File

@ -4,8 +4,8 @@
"description": "A Discord ticket/support - an open-source & self-hosted bot",
"main": "index.js",
"dependencies": {
"discord.js": "^11.4.2",
"leekslazylogger": "^1.1.3"
"discord.js": "^11.5.1",
"leekslazylogger": "^1.1.7"
},
"devDependencies": {},
"scripts": {