mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
fixed new.js
This commit is contained in:
parent
d4522cd729
commit
60044a1e70
140
commands/new.js
140
commands/new.js
@ -11,108 +11,114 @@ module.exports = {
|
|||||||
args: true,
|
args: true,
|
||||||
cooldown: config.cooldown,
|
cooldown: config.cooldown,
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
execute(message, args) {
|
execute(message, args) {
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
// command starts here
|
// command starts here
|
||||||
message.delete();
|
message.delete();
|
||||||
let topic = args.join(" ");
|
let topic = args.join(" ");
|
||||||
|
|
||||||
// let num = randomString({
|
// let num = randomString({
|
||||||
// length: 4,
|
// length: 4,
|
||||||
// numeric: true,
|
// numeric: true,
|
||||||
// letters: false,
|
// letters: false,
|
||||||
// special: 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}`;
|
let chan = `ticket-${id}`;
|
||||||
|
|
||||||
if(message.guild.channels.some(channel => chan.includes(channel.name))) {
|
if (message.guild.channels.some(channel => chan.includes(channel.name))) {
|
||||||
if(config.useEmbeds){
|
if (config.useEmbeds) {
|
||||||
const err1 = new Discord.RichEmbed()
|
const err1 = new Discord.RichEmbed()
|
||||||
.setColor("#E74C3C")
|
.setColor("#E74C3C")
|
||||||
.setDescription(`:x: You already have an open ticket.`)
|
.setDescription(`:x: You already have an open ticket.`)
|
||||||
return message.channel.send(err1)
|
return message.channel.send(err1)
|
||||||
} else {
|
} else {
|
||||||
message.channel.send(`:x: You already have an open ticket.`)
|
message.channel.send(`:x: You already have an open ticket.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
message.guild.createChannel(`ticket-${id}`).then(async c => {
|
message.guild.createChannel(`ticket-${id}`, {
|
||||||
c.setParent(config.ticketsCat);
|
type: 'text'
|
||||||
// let supportRole = message.guild.roles.find(`id`, config.supportRole)
|
}).then(async c => {
|
||||||
|
c.setParent(config.ticketsCat);
|
||||||
|
// let supportRole = message.guild.roles.find(`id`, config.supportRole)
|
||||||
let supportRole = message.guild.roles.get(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, {
|
c.overwritePermissions(message.guild.defaultRole, {
|
||||||
VIEW_CHANNEL: false,
|
VIEW_CHANNEL: false,
|
||||||
SEND_MESSAGES: false
|
SEND_MESSAGES: false
|
||||||
})
|
})
|
||||||
c.overwritePermissions(message.member, {
|
c.overwritePermissions(message.member, {
|
||||||
VIEW_CHANNEL: true,
|
VIEW_CHANNEL: true,
|
||||||
SEND_MESSAGES: true
|
SEND_MESSAGES: true
|
||||||
})
|
})
|
||||||
c.overwritePermissions(supportRole, {
|
c.overwritePermissions(supportRole, {
|
||||||
VIEW_CHANNEL: true,
|
VIEW_CHANNEL: true,
|
||||||
SEND_MESSAGES: true
|
SEND_MESSAGES: true
|
||||||
})
|
})
|
||||||
c.setTopic(`${message.author} | ${topic}`);
|
c.setTopic(`${message.author} | ${topic}`);
|
||||||
if(config.tagHereOnly){
|
if (config.tagHereOnly) {
|
||||||
await c.send(`@here, a user has created a new ticket.\n`);
|
await c.send(`@here, a user has created a new ticket.\n`);
|
||||||
} else {
|
} else {
|
||||||
await c.send(`<@&${config.supportRole}>, a user has created a new ticket.\n`);
|
await c.send(`<@&${config.supportRole}>, a user has created a new ticket.\n`);
|
||||||
};
|
};
|
||||||
|
|
||||||
if(config.ticketImage) {
|
if (config.ticketImage) {
|
||||||
await c.send(`__**Here's your ticket channel, ${message.author}**__`,{files: [`./image.png`]})
|
await c.send(`__**Here's your ticket channel, ${message.author}**__`, {
|
||||||
|
files: [`./image.png`]
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
await c.send(`__**Here's your ticket channel, ${message.author}**__`)
|
await c.send(`__**Here's your ticket channel, ${message.author}**__`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const created = new Discord.RichEmbed()
|
const created = new Discord.RichEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setDescription(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
|
.setDescription(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
const welcome = new Discord.RichEmbed()
|
const welcome = new Discord.RichEmbed()
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
|
.setDescription(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
|
||||||
|
|
||||||
|
|
||||||
if(config.useEmbeds) {
|
if (config.useEmbeds) {
|
||||||
message.channel.send(created)
|
message.channel.send(created)
|
||||||
let w = await c.send(welcome)
|
let w = await c.send(welcome)
|
||||||
await w.pin();
|
await w.pin();
|
||||||
// c.fetchMessage(c.lastMessageID).delete()
|
// c.fetchMessage(c.lastMessageID).delete()
|
||||||
} else {
|
} else {
|
||||||
message.channel.send(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
|
message.channel.send(`Your ticket (${c}) has been created.\nPlease read the information sent and follow any instructions given.`)
|
||||||
let w = await c.send(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
|
let w = await c.send(`**Ticket topic:** \`${topic}\`\n\n${config.ticketText}`)
|
||||||
await w.pin()
|
await w.pin()
|
||||||
// c.fetchMessage(c.lastMessageID).delete()
|
// c.fetchMessage(c.lastMessageID).delete()
|
||||||
|
|
||||||
}
|
}
|
||||||
// log
|
// log
|
||||||
if(config.useEmbeds) {
|
if (config.useEmbeds) {
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
|
.setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
|
||||||
.setTitle("New Ticket")
|
.setTitle("New Ticket")
|
||||||
.setColor(config.colour)
|
.setColor(config.colour)
|
||||||
.setDescription(`\`${topic}\``)
|
.setDescription(`\`${topic}\``)
|
||||||
.addField("Username", message.author, true)
|
.addField("Username", message.author, true)
|
||||||
.addField("Channel", c, true)
|
.addField("Channel", c, true)
|
||||||
.setFooter(`DiscordTickets`)
|
.setFooter(`DiscordTickets`)
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
client.channels.get(config.logChannel).send({embed})
|
client.channels.get(config.logChannel).send({
|
||||||
} else {
|
embed
|
||||||
client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
|
})
|
||||||
}
|
} else {
|
||||||
|
client.channels.get(config.logChannel).send(`New ticket created by **${message.author.tag} (${message.author.id})**`);
|
||||||
|
}
|
||||||
log.info(`${message.author.tag} created a new ticket (#ticket-${id})`)
|
log.info(`${message.author.tag} created a new ticket (#ticket-${id})`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// command ends here
|
// command ends here
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -4,8 +4,8 @@
|
|||||||
"description": "A Discord ticket/support - an open-source & self-hosted bot",
|
"description": "A Discord ticket/support - an open-source & self-hosted bot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.5.1",
|
||||||
"leekslazylogger": "^1.1.3"
|
"leekslazylogger": "^1.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user