Compare commits

...
3 Commits
Author SHA1 Message Date
DJj123dj 5fc3ba3279 Update checker.js 2022-04-02 17:03:13 +02:00
DJj123dj 6df23d84bc v1.3.2
This is the first stable version of open-ticket 1.3
2022-04-02 16:38:00 +02:00
DJj123dj 8cab4cc686 v1.3.1
Bug fixes
2022-03-31 18:38:49 +02:00
12 changed files with 443 additions and 81 deletions
+14 -6
View File
@@ -1,12 +1,16 @@
# open-ticket # open-ticket
[![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) [![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3)
[![version](https://img.shields.io/badge/version-1.3.0%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.0) [![version](https://img.shields.io/badge/version-1.3.2%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.2)
[![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) [![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages)
[![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE)
This is an open-source discord ticket bot, you can configure it and it comes with cool features like transcripts & custom options! This is an open-source discord ticket bot, you can configure it and it comes with cool features like transcripts & custom options!
<img src="logo.png" alt="Open Ticket logo" style="height: 300px; width:300px;"/> <img src="logo.png" alt="Open Ticket logo" style="height: 200px; width:200px;"/>
[![announcement](https://img.shields.io/badge/new%20announcement!-open--ticket%20v1.4.0-red.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/discussions/3)
[![q&a](https://img.shields.io/badge/Q&A-click%20here-blue.svg?style=flat-square)](./documentation/Q&A.md)
## features ## features
- discord interaction buttons - discord interaction buttons
@@ -27,7 +31,7 @@ This is an open-source discord ticket bot, you can configure it and it comes wit
You can clone or download this project. You can clone or download this project.
### packages ### packages
- canvas => version `latest` - chalk => version `latest`
- discord.js => version `latest` - discord.js => version `latest`
- express => version `latest` - express => version `latest`
- node-localstorage => version `latest` - node-localstorage => version `latest`
@@ -41,7 +45,7 @@ if there are any errors, you can open an **issue on github** or **contact me in
### config ### config
Our config documentation is moved to another file: Our config documentation is moved to another file:
[click here to view](CONFIG.md) [click here to view](./documentation/CONFIG.md)
### intents & permissions ### intents & permissions
In the discord developer portal in the "bot" panel you will find 3 switches under the title "Gateaway Intents". The following switches should always be turned on In the discord developer portal in the "bot" panel you will find 3 switches under the title "Gateaway Intents". The following switches should always be turned on
@@ -51,10 +55,14 @@ In the discord developer portal in the "bot" panel you will find 3 switches unde
To work the best, the bot needs `ADMINISTRATOR` permissions. To work the best, the bot needs `ADMINISTRATOR` permissions.
You can also configure your own permissions You can also configure your own permissions
## v1.4.0 announcement
Hello everyone, soon open-ticket v1.4.0 will be launched, it contains a lot of new features. You can view them below.
[click here to view the announcement](https://github.com/DJj123dj/open-ticket/discussions/3)
## information ## information
_v1.3.0_ _v1.3.2_
changelog: [click here](CHANGELOG.md) changelog: [click here](./documentation/CHANGELOG.md)
© 2022 - DJdj Development | [website](https://www.dj-dj.be) | [discord](https://discord.com/invite/26vT9wt3n3) © 2022 - DJdj Development | [website](https://www.dj-dj.be) | [discord](https://discord.com/invite/26vT9wt3n3)
+214
View File
@@ -0,0 +1,214 @@
module.exports = async () => {
const chalk = await (await import("chalk")).default
const config = require("./config.json")
var errorList = []
var isError = false
var warnList = []
var isWarn = false
const createError = (message) => {
isError = true
errorList.push("open-ticket ERROR: "+message)
}
const createWarn = (message) => {
isWarn = true
warnList.push("open-ticket WARNING: "+message)
}
//checker
//token
if (config.auth_token.includes(" ")){
createError("invalid token | there are spaces in your token!")
}
if (config.auth_token.length < 40){
createError("invalid token | length not correct!")
}
//color
if (!config.main_color.startsWith("#")){
createError("color not detected | 'main_color' doesn't start with a '#'!")
}
if (config.main_color.length > 7 || config.main_color.length < 7){
createError("color not detected | 'main_color' is not a valid hex color!")
}
//admin
if (config.botperms_role.includes(" ")){
createError("invalid role id | 'botperms_role' is not a valid role id!")
}
if (config.botperms_role.length > 20|| config.botperms_role.length < 16){
createError("invalid role id | 'botperms_role' is not a valid role id!")
}
//prefix
if (config.prefix == ""){
createError("no prefix | 'prefix' is empty!")
}
if (config.prefix.length > 3){
createWarn("long prefix | your prefix is a little bit long!")
}
//status
if (config.status.enabled && (config.status.type != "PLAYING" && config.status.type != "LISTENING" && config.status.type != "WATCHING" && config.status.type != "CUSTOM")){
createError("status error | 'status/type' is invalid!")
}
if (config.status.enabled && config.status.text.length < 1){
createError("status error | 'status/text' must be at least 1 character long!")
}
//ticketchannel
if (config.system.ticket_channel.includes(" ")){
createWarn("invalid channel id | 'system/ticket_channel' is not a valid channel id!")
}
if (config.system.ticket_channel.length < 1){
createWarn("no ticket channel | 'system/ticket_channel' is empty")
}else if (config.system.ticket_channel.length > 20|| config.system.ticket_channel.length < 16){
createWarn("invalid channel id | 'system/ticket_channel' is not a valid channel id!")
}
//maxticket
if (config.system.max_allowed_tickets < 1){
createWarn("no tickets | if 'system/max_allowed_tickets' is under 1 you can't create any ticket")
}
//category
if (config.system.enable_category == true && config.system.ticket_category.includes(" ")){
createError("invalid category id | 'system/ticket_category' is not a valid category id!")
}
if (config.system.enable_category && config.system.ticket_category.length > 20 || config.system.ticket_category.length < 16){
createError("invalid category id | 'system/ticket_category' is not a valid category id!")
}
//everyoneaccess
if (config.system["has@everyoneaccess"] == true){
createWarn("access | everyone has access to the tickets!")
}
//memberrole
if (config.system.member_role.includes(" ")){
createError("invalid role id | 'system/member_role' is not a valid role id!")
}
if (config.system.member_role.length > 20){
createError("invalid role id | 'system/member_role' is not a valid role id!")
}
if (config.system.member_role == "" || config.system.member_role == " " || config.system.member_role == "false" || config.system.member_role == "null" || config.system.member_role == "0"){
createWarn("no member role | 'system/member_role' is not valid so technically everyone can view a ticket!")
}
//transcript
if (config.system.enable_transcript && config.system.transcript_channel.includes(" ")){
createError("invalid channel id | 'system/transcript_channel' is not a valid channel id!")
}
if (config.system.enable_transcript && config.system.transcript_channel.length > 20 || config.system.transcript_channel.length < 16){
createError("invalid channel id | 'system/transcript_channel' is not a valid channel id!")
}
//messages
if (config.messages.general.nopermissions.length < 1){
createError("no message | 'messages/general/nopermissions' is empty!")
}
if (config.messages.ticket.newTicketEmbed.length < 1){
createError("no message | 'messages/ticket/newTicketEmbed' is empty!")
}
if (config.messages.dm.alreadyCreated.length < 1){
createError("no message | 'messages/dm/alreadyCreated' is empty!")
}
if (config.messages.dm.newTicket.length < 1){
createError("no message | 'messages/dm/newTicket' is empty!")
}
if (config.messages.dm.closeTicket.length < 1){
createError("no message | 'messages/dm/closeTicket' is empty!")
}
//layout
const checkLayout = (layout,layoutname,color,footer,thumbnail) => {
if (color){
if (!layout.customColor.startsWith("#")){
createError("color not detected | 'layout/"+layoutname+"/customColor' doesn't start with a '#'!")
}
if (layout.customColor.length > 7 || layout.customColor.length < 7){
createError("color not detected | 'layout/"+layoutname+"/customColor' is not a valid hex color!")
}
}
if (footer){
if (layout.footer.length < 1){
createError("no footer | 'layout/"+layoutname+"/footer' doesn't have a footer!")
}
}
if (thumbnail){
if (!layout.thumbnailURL.startsWith("https://") && !layout.thumbnailURL.startsWith("http://")){
createError("thumbnail | the thumbnail url in 'layout/"+layoutname+"/thumbnailURL' is not a valid url!")
}
}
}
checkLayout(config.layout.ticketEmbed,"ticketEmbed",config.layout.ticketEmbed.customColorEnabled,config.layout.ticketEmbed.footerEnabled,config.layout.ticketEmbed.thumbnailEnabled)
checkLayout(config.layout.ticketMsg,"ticketMsg",config.layout.ticketMsg.customColorEnabled,config.layout.ticketMsg.footerEnabled,config.layout.ticketMsg.thumbnailEnabled)
checkLayout(config.layout.transcripts,"transcripts",config.layout.transcripts.customColorEnabled,false,config.layout.transcripts.thumbnailEnabled)
const checkOption = (ticket,ticketname,enabled,urlmode) => {
if (enabled){
if (ticket.icon.length > 0){
const emojiRegex = /\p{Emoji}/u
const isEmoji = emojiRegex.test(ticket.icon)
if (isEmoji == false){
createWarn("invalid emoji | 'options/"+ticketname+"/icon' is not a valid emoji (code can be wrong)")
}
}
if (ticket.description.length < 1){
createWarn("no description | 'options/"+ticketname+"/description' is empty")
}
if (ticket.name.length < 1){
createWarn("no description | 'options/"+ticketname+"/name' is empty")
}
if (ticket.channel_prefix.length < 1){
createWarn("no description | 'options/"+ticketname+"/channel_prefix' is empty")
}
if (ticket.isURL == true && ticket.color != "red" && ticket.color != "blue" && ticket.color != "green" && ticket.color != "gray" && ticket.color != "none"){
createWarn("invalid button color | 'options/"+ticketname+"/color' must be one of (red,green,blue,gray,none)")
}
if (urlmode && (!ticket.url.startsWith("https://") && !ticket.url.startsWith("http://"))){
createError("url invalid | the url in 'options/"+ticketname+"/url' is not a valid url!")
}
}
return
}
checkOption(config.options.ticket1,"ticket1",config.options.ticket1.enabled,config.options.ticket1.isURL)
checkOption(config.options.ticket2,"ticket2",config.options.ticket2.enabled,config.options.ticket2.isURL)
checkOption(config.options.ticket3,"ticket3",config.options.ticket3.enabled,config.options.ticket3.isURL)
checkOption(config.options.ticket4,"ticket4",config.options.ticket4.enabled,config.options.ticket4.isURL)
checkOption(config.options.ticket5,"ticket5",config.options.ticket5.enabled,config.options.ticket5.isURL)
checkOption(config.options.ticket6,"ticket6",config.options.ticket6.enabled,config.options.ticket6.isURL)
//the end
if (errorList.length > 0 || warnList.length > 0){
console.log("REPORT:\n===========================")
}
warnList.forEach((w) => {
const splitw = w.split("'")
if (splitw.length > 1){
var splitstring = chalk.yellow(splitw[0])+chalk.blue("'"+splitw[1]+"'")+chalk.yellow(splitw[2])
}else {var splitstring = chalk.yellow(splitw[0])}
console.log(splitstring)
})
errorList.forEach((e) => {
const splite = e.split("'")
if (splite.length > 1){
var splitstring = chalk.red(splite[0])+chalk.blue("'"+splite[1]+"'")+chalk.red(splite[2])
}else {var splitstring = chalk.red(splite[0])}
console.log(splitstring)
})
if (isError){
console.log("===========================")
console.log("=> "+chalk.bgRed("your bot doesn't work if you don't fix the above errors!"))
if (isWarn){
console.log("\n=> "+chalk.bgYellow("if you ignore warns, some things may work differently than expected!"))
}
process.exit(0)
}else if (isWarn == true && isError == false){
console.log("===========================")
console.log("=> "+chalk.bgYellow("if you ignore warns, some things may work differently than expected!"))
}
}
+3 -4
View File
@@ -7,16 +7,15 @@ const config = require("../config.json")
module.exports = () => { module.exports = () => {
client.on("messageCreate",(msg) => { client.on("messageCreate",(msg) => {
var args = msg.content.split(" ") var args = msg.content.split(" ")
if (args[0] == config.prefix+"resetdatabase"){ if (args[0] == config.prefix+"resetdatabase" || args[0] == config.prefix+"resetdb"){
if (msg.author.id == client.application.owner.id){
const databaseEmbed = new discord.MessageEmbed() const databaseEmbed = new discord.MessageEmbed()
.setColor(config.main_color) .setColor(config.main_color)
.setTitle("How to reset the database:") .setTitle("How to reset the database:")
.setDescription("1: Go to the folder `./storage` in your bot's directory.\n\n2: If posible remove the folders\n`./tickets`, `./transcripts` & `./userTickets`\nfrom the folder `./storage`\n\n3: Restart the bot") .setDescription("1: Go to the folder `./storage` in your bot's directory.\n\n2: If posible remove the folders\n`./tickets`, `./transcripts` & `./userTickets`\nfrom the folder `./storage`\n\n3: Restart the bot")
.setFooter("if it doesn't work, create an issue on github or DM me on discord!") .setFooter({text:"if it doesn't work, create an issue on github or DM me on discord!"})
msg.channel.send({embeds:[databaseEmbed]}) msg.channel.send({embeds:[databaseEmbed]})
} if (config.logs){console.log("[command] "+config.prefix+"resetdatabase (user:"+msg.author.username+")")}
} }
}) })
} }
+69 -16
View File
@@ -12,7 +12,9 @@ module.exports = () => {
return return
} }
var currentTicketButtons = 0
var ticketButton = new discord.MessageActionRow() var ticketButton = new discord.MessageActionRow()
var ticketButton2 = new discord.MessageActionRow()
const getColor = (color) => { const getColor = (color) => {
if (color.toLowerCase() == "red"){ if (color.toLowerCase() == "red"){
@@ -31,8 +33,16 @@ module.exports = () => {
} }
if (config.options.ticket1.enabled){ if (config.options.ticket1.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket1.isURL == false){ if (config.options.ticket1.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket1") .setCustomId("newTicket1")
.setDisabled(false) .setDisabled(false)
@@ -40,7 +50,7 @@ module.exports = () => {
.setEmoji(config.options.ticket1.icon) .setEmoji(config.options.ticket1.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -49,10 +59,17 @@ module.exports = () => {
) )
} }
} }
if (config.options.ticket2.enabled){ if (config.options.ticket2.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket2.isURL == false){ if (config.options.ticket2.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket2") .setCustomId("newTicket2")
.setDisabled(false) .setDisabled(false)
@@ -60,7 +77,7 @@ module.exports = () => {
.setEmoji(config.options.ticket2.icon) .setEmoji(config.options.ticket2.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -71,8 +88,16 @@ module.exports = () => {
} }
if (config.options.ticket3.enabled){ if (config.options.ticket3.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket3.isURL == false){ if (config.options.ticket3.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket3") .setCustomId("newTicket3")
.setDisabled(false) .setDisabled(false)
@@ -80,7 +105,7 @@ module.exports = () => {
.setEmoji(config.options.ticket3.icon) .setEmoji(config.options.ticket3.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -91,8 +116,16 @@ module.exports = () => {
} }
if (config.options.ticket4.enabled){ if (config.options.ticket4.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket4.isURL == false){ if (config.options.ticket4.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket4") .setCustomId("newTicket4")
.setDisabled(false) .setDisabled(false)
@@ -100,7 +133,7 @@ module.exports = () => {
.setEmoji(config.options.ticket4.icon) .setEmoji(config.options.ticket4.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -111,8 +144,16 @@ module.exports = () => {
} }
if (config.options.ticket5.enabled){ if (config.options.ticket5.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket5.isURL == false){ if (config.options.ticket5.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket5") .setCustomId("newTicket5")
.setDisabled(false) .setDisabled(false)
@@ -120,7 +161,7 @@ module.exports = () => {
.setEmoji(config.options.ticket5.icon) .setEmoji(config.options.ticket5.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -131,8 +172,16 @@ module.exports = () => {
} }
if (config.options.ticket6.enabled){ if (config.options.ticket6.enabled){
if (currentTicketButtons < 4){
var localTicketButton = ticketButton
}else{
var localTicketButton = ticketButton2
}
currentTicketButtons = currentTicketButtons + 1
if (config.options.ticket6.isURL == false){ if (config.options.ticket6.isURL == false){
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setCustomId("newTicket6") .setCustomId("newTicket6")
.setDisabled(false) .setDisabled(false)
@@ -140,7 +189,7 @@ module.exports = () => {
.setEmoji(config.options.ticket6.icon) .setEmoji(config.options.ticket6.icon)
) )
}else{ }else{
ticketButton.addComponents( localTicketButton.addComponents(
new discord.MessageButton() new discord.MessageButton()
.setDisabled(false) .setDisabled(false)
.setStyle("LINK") .setStyle("LINK")
@@ -171,7 +220,7 @@ module.exports = () => {
}else{ticketEmbed.setColor(config.main_color)} }else{ticketEmbed.setColor(config.main_color)}
if (config.layout.ticketMsg.footerEnabled){ if (config.layout.ticketMsg.footerEnabled){
ticketEmbed.setFooter(config.layout.ticketMsg.footer) ticketEmbed.setFooter({text:config.layout.ticketMsg.footer})
} }
if (config.layout.ticketMsg.thumbnailEnabled){ if (config.layout.ticketMsg.thumbnailEnabled){
ticketEmbed.setThumbnail(config.layout.ticketMsg.thumbnailURL) ticketEmbed.setThumbnail(config.layout.ticketMsg.thumbnailURL)
@@ -180,10 +229,14 @@ module.exports = () => {
ticketEmbed.setDescription("**Create a ticket:**\nClick one of the buttons below to create a ticket.\n\n__choose a category:__"+categorylist+"\n\n**watch out:**_You can only create "+config.system.max_allowed_tickets+" ticket(s) at a time!_") ticketEmbed.setDescription("**Create a ticket:**\nClick one of the buttons below to create a ticket.\n\n__choose a category:__"+categorylist+"\n\n**watch out:**_You can only create "+config.system.max_allowed_tickets+" ticket(s) at a time!_")
if (currentTicketButtons <= 4){
var embedComponents = [ticketButton]
}else{var embedComponents = [ticketButton,ticketButton2]}
msg.channel.send({embeds:[ticketEmbed],components:[ticketButton]}) msg.channel.send({embeds:[ticketEmbed],components:embedComponents})
if (config.logs){console.log("[command] "+config.prefix+"ticket msg (user:"+msg.author.username+")")}
if (config.logs){console.log("[system] created ticket message")}
} }
}) })
} }
+15 -3
View File
@@ -14,13 +14,14 @@ module.exports = () => {
.setTitle("Ticket commands") .setTitle("Ticket commands")
const prefix = config.prefix const prefix = config.prefix
TicketHelpMsg.setDescription("**Go to <#"+config.system.ticket_channel+"> to create a ticket!**\n\n`"+prefix+"ticket msg` ➜ _Admin command._\n`"+prefix+"ticket rename` ➜ _Rename a ticket (no spaces)._\n`"+prefix+"ticket close` ➜ _Close a ticket._\n`"+prefix+"ticket add <user>` ➜ _Add a user to the ticket._\n`"+prefix+"ticket remove <user>` ➜ _Remove a user from the ticket._\n`"+prefix+"resetdatabase` ➜ _Steps to reset the database._") TicketHelpMsg.setDescription("**Go to <#"+config.system.ticket_channel+"> to create a ticket!**\n\n`"+prefix+"ticket msg` ➜ _Admin command._\n`"+prefix+"ticket rename` ➜ _Rename a ticket (no spaces)._\n`"+prefix+"ticket close` ➜ _Close a ticket._\n`"+prefix+"ticket add <user>` ➜ _Add a user to the ticket._\n`"+prefix+"ticket remove <user>` ➜ _Remove a user from the ticket._\n`"+prefix+"resetdatabase` ➜ _Steps to reset the database._\n`"+prefix+"resetdb` ➜ _Also database stuff._")
if (config.credits){ if (config.credits){
TicketHelpMsg.setFooter("Open-Ticket by DJdj Development | view on github for source code") TicketHelpMsg.setFooter({text:"Open-Ticket by DJdj Development | view on github for source code"})
} }
msg.channel.send({embeds:[TicketHelpMsg]}) msg.channel.send({embeds:[TicketHelpMsg]})
if (config.logs){console.log("[command] "+config.prefix+"ticket help (user:"+msg.author.username+")")}
} }
}) })
@@ -44,6 +45,7 @@ module.exports = () => {
.setTitle("Close this ticket:") .setTitle("Close this ticket:")
msg.channel.send({embeds:[CloseMsg]}) msg.channel.send({embeds:[CloseMsg]})
if (config.logs){console.log("[command] "+config.prefix+"ticket close (user:"+msg.author.username+")")}
}) })
@@ -65,15 +67,18 @@ module.exports = () => {
} }
var name = args[2] var name = args[2]
var oldname = msg.channel.name
msg.channel.messages.fetchPinned().then(msglist => { msg.channel.messages.fetchPinned().then(msglist => {
if (msglist.last().author.id == client.user.id){ if (msglist.last().author.id == client.user.id){
msg.channel.send({content:"De naam is veranderd!"}).then(rmsg => { msg.channel.send({content:"The name from the ticket is changed!"}).then(rmsg => {
rmsg.channel.setName(name) rmsg.channel.setName(name)
if (config.logs){console.log("[system] renamed a ticket (name:"+oldname+",newname:"+name+")")}
}) })
}else{ }else{
msg.channel.send({content:"You are not in a ticket!"}) msg.channel.send({content:"You are not in a ticket!"})
} }
}) })
if (config.logs){console.log("[command] "+config.prefix+"ticket rename (user:"+msg.author.username+")")}
} }
}) })
@@ -102,8 +107,11 @@ module.exports = () => {
} }
msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true}) msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
}) })
var loguser = msg.mentions.users.first()
if (config.logs){console.log("[command] "+config.prefix+"ticket add "+loguser.username+" (user:"+msg.author.username+")")}
} }
}) })
@@ -132,8 +140,12 @@ module.exports = () => {
} }
msg.channel.permissionOverwrites.delete(user.id) msg.channel.permissionOverwrites.delete(user.id)
if (config.logs){console.log("[system] removed user from ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
}) })
var loguser = msg.mentions.users.first()
if (config.logs){console.log("[command] "+config.prefix+"ticket remove "+loguser.username+" (user:"+msg.author.username+")")}
} }
}) })
} }
+43 -31
View File
@@ -47,16 +47,22 @@ module.exports = () => {
//set ticketName //set ticketName
if (interaction.customId == "newTicket1"){ if (interaction.customId == "newTicket1"){
var ticketName = config.options.ticket1.channel_prefix+ticketNumber var ticketName = config.options.ticket1.channel_prefix+ticketNumber
var logsname = config.options.ticket1.name
}else if (interaction.customId == "newTicket2"){ }else if (interaction.customId == "newTicket2"){
var ticketName = config.options.ticket2.channel_prefix+ticketNumber var ticketName = config.options.ticket2.channel_prefix+ticketNumber
var logsname = config.options.ticket2.name
}else if (interaction.customId == "newTicket3"){ }else if (interaction.customId == "newTicket3"){
var ticketName = config.options.ticket3.channel_prefix+ticketNumber var ticketName = config.options.ticket3.channel_prefix+ticketNumber
var logsname = config.options.ticket3.name
}else if (interaction.customId == "newTicket4"){ }else if (interaction.customId == "newTicket4"){
var ticketName = config.options.ticket4.channel_prefix+ticketNumber var ticketName = config.options.ticket4.channel_prefix+ticketNumber
var logsname = config.options.ticket4.name
}else if (interaction.customId == "newTicket5"){ }else if (interaction.customId == "newTicket5"){
var ticketName = config.options.ticket5.channel_prefix+ticketNumber var ticketName = config.options.ticket5.channel_prefix+ticketNumber
var logsname = config.options.ticket5.name
}else if (interaction.customId == "newTicket6"){ }else if (interaction.customId == "newTicket6"){
var ticketName = config.options.ticket6.channel_prefix+ticketNumber var ticketName = config.options.ticket6.channel_prefix+ticketNumber
var logsname = config.options.ticket6.name
} }
//set category //set category
@@ -64,6 +70,8 @@ module.exports = () => {
var Category = config.system.ticket_category var Category = config.system.ticket_category
}else{var Category = null} }else{var Category = null}
var permissionsArray = []
//set everyone allowed //set everyone allowed
if (config.system['has@everyoneaccess']){ if (config.system['has@everyoneaccess']){
var everyoneAllowPerms = ["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] var everyoneAllowPerms = ["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
@@ -72,34 +80,35 @@ module.exports = () => {
var everyoneAllowPerms = [] var everyoneAllowPerms = []
var everyoneDenyPerms = ["VIEW_CHANNEL"] var everyoneDenyPerms = ["VIEW_CHANNEL"]
} }
permissionsArray.push({
id:interaction.member.id,
type:"member",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
})
permissionsArray.push({
id:config.botperms_role,
type:"role",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
})
permissionsArray.push({
id:interaction.guild.id,
type:"role",
allow:everyoneAllowPerms,
deny:everyoneDenyPerms
})
if (config.system.member_role == "" || config.system.member_role == " " || config.system.member_role == "false" || config.system.member_role == "null" || config.system.member_role == "0"){
permissionsArray.push({
id:config.system.member_role,
type:"role",
deny:["VIEW_CHANNEL"]
})
}
//create the channel //create the channel
interaction.guild.channels.create(ticketName,{ interaction.guild.channels.create(ticketName,{
type:"GUILD_TEXT", type:"GUILD_TEXT",
parent:Category, parent:Category,
permissionOverwrites:[ permissionOverwrites:permissionsArray
{
id:interaction.member.id,
type:"member",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
},
{
id:config.botperms_role,
type:"role",
allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"]
},
{
id:config.system.member_role,
type:"role",
deny:["VIEW_CHANNEL"]
},
{
id:interaction.guild.id,
type:"role",
allow:everyoneAllowPerms,
deny:everyoneDenyPerms
}
]
}).then(tChannel => { }).then(tChannel => {
userTicketStorage.setItem(tChannel.id,interaction.member.id) userTicketStorage.setItem(tChannel.id,interaction.member.id)
@@ -110,7 +119,7 @@ module.exports = () => {
}else{ticketEmbed.setColor(config.main_color)} }else{ticketEmbed.setColor(config.main_color)}
if (config.layout.ticketEmbed.footerEnabled){ if (config.layout.ticketEmbed.footerEnabled){
ticketEmbed.setFooter(config.layout.ticketEmbed.footer) ticketEmbed.setFooter({text:"config.layout.ticketEmbed.footer"})
} }
if (config.layout.ticketEmbed.thumbnailEnabled){ if (config.layout.ticketEmbed.thumbnailEnabled){
ticketEmbed.setThumbnail(config.layout.ticketEmbed.thumbnailURL) ticketEmbed.setThumbnail(config.layout.ticketEmbed.thumbnailURL)
@@ -121,6 +130,7 @@ module.exports = () => {
tChannel.send({content:"<@"+interaction.member.id+"> <@&"+config.botperms_role+">",embeds:[ticketEmbed],components:[closeButton]}).then(firstmsg => { tChannel.send({content:"<@"+interaction.member.id+"> <@&"+config.botperms_role+">",embeds:[ticketEmbed],components:[closeButton]}).then(firstmsg => {
firstmsg.pin() firstmsg.pin()
}) })
if (config.logs){console.log("[system] created a new ticket (name:"+logsname+",user:"+interaction.user.username+")")}
}) })
@@ -227,16 +237,16 @@ module.exports = () => {
} }
var transcriptEmbed = new discord.MessageEmbed() var transcriptEmbed = new discord.MessageEmbed()
.setColor(transcriptColor) .setColor(transcriptColor)
.setAuthor(interaction.channel.name + " - ticket created by "+getuserNAME) .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME})
.setTitle("There is a new transcript!") .setTitle("There is a new transcript!")
.setDescription(splittedTranscript[0]) .setDescription(splittedTranscript[0])
.setFooter("ticket closed by "+interaction.member.user.username) .setFooter({text:"ticket closed by "+interaction.member.user.username})
.setThumbnail(transcriptThumbnail) .setThumbnail(transcriptThumbnail)
if (transcript.length > 4000){ if (transcript.length > 4000){
var transcriptEmbed2 = new discord.MessageEmbed() var transcriptEmbed2 = new discord.MessageEmbed()
.setColor(transcriptColor) .setColor(transcriptColor)
.setAuthor(interaction.channel.name + " - ticket created by "+getuserNAME) .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME})
.setTitle("transcript #2") .setTitle("transcript #2")
.setDescription(splittedTranscript[1]) .setDescription(splittedTranscript[1])
.setFooter("ticket closed by "+interaction.member.user.username) .setFooter("ticket closed by "+interaction.member.user.username)
@@ -244,10 +254,10 @@ module.exports = () => {
var transcriptEmbed3 = new discord.MessageEmbed() var transcriptEmbed3 = new discord.MessageEmbed()
.setColor(transcriptColor) .setColor(transcriptColor)
.setAuthor(interaction.channel.name + " - ticket created by "+getuserNAME) .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME})
.setTitle("transcript #3") .setTitle("transcript #3")
.setDescription(splittedTranscript[1]) .setDescription(splittedTranscript[1])
.setFooter("ticket closed by "+interaction.member.user.username) .setFooter({text:"ticket closed by "+interaction.member.user.username})
.setThumbnail(transcriptThumbnail) .setThumbnail(transcriptThumbnail)
client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2,transcriptEmbed3]}) client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2,transcriptEmbed3]})
@@ -255,10 +265,10 @@ module.exports = () => {
}else if (transcript.length > 2000){ }else if (transcript.length > 2000){
var transcriptEmbed2 = new discord.MessageEmbed() var transcriptEmbed2 = new discord.MessageEmbed()
.setColor(transcriptColor) .setColor(transcriptColor)
.setAuthor(interaction.channel.name + " - ticket created by "+getuserNAME) .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME})
.setTitle("transcript #2") .setTitle("transcript #2")
.setDescription(splittedTranscript[1]) .setDescription(splittedTranscript[1])
.setFooter("ticket closed by "+interaction.member.user.username) .setFooter({text:"ticket closed by "+interaction.member.user.username})
.setThumbnail(transcriptThumbnail) .setThumbnail(transcriptThumbnail)
client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2]}) client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2]})
@@ -270,6 +280,8 @@ module.exports = () => {
interaction.channel.delete() interaction.channel.delete()
if (config.logs){console.log("[system] closed a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")}
ticketStorage.setItem(getuserID,Number(ticketStorage.getItem(getuserID)) - 1) ticketStorage.setItem(getuserID,Number(ticketStorage.getItem(getuserID)) - 1)
+3 -3
View File
@@ -1,15 +1,15 @@
{ {
"server_name":"Ticket Bot",
"server_logo":"https://www.example.com/another-example/yourlogo.png",
"bot_name":"Wumpus", "bot_name":"Wumpus",
"main_color":"#fffff", "main_color":"#fffff",
"auth_token":"the bot's auth token", "auth_token":"the bot's auth token",
"botperms_role":"the id from an admin role (they can do admin things with the bot)", "botperms_role":"the id from an admin role (they can do admin things with the bot)",
"prefix":"!", "prefix":"!",
"logs":true,
"credits":true, "credits":true,
"status":{ "status":{
"type":"PLAYING | STREAMING | LISTENING | WATCHING | CUSTOM | COMPETING", "enabled":true,
"type":"PLAYING | LISTENING | WATCHING | CUSTOM",
"text":"!ticket" "text":"!ticket"
}, },
@@ -1,5 +1,36 @@
# changelog # changelog
## v1.3.2
### added:
- an alias for !resetdatabase: !resetdb
- you need the "chalk" library now!
- checker.js
- "enabled" option for status
- better console logs
- enable logs option to config
### fixed
- a bug that crashed the bot on using the command !resetdatabase
- "member_role" in config is optional but not recommended
- fixed crash on startup
- fixed bug where the bot crashes by using transcripts
- changed package.json
### removed
- "canvas" library is not longer required
- removed "server_icon" & "server_name" from config
## v1.3.1
### added:
- Q&A in the README.md
- v1.4.0 announcement
### fixed
- a bug that happend when you created too much tickets
- deprecation warnings (setAuthor & setFooter)
- the logo in README.md is smaller now
- markdown files relocated
- fixed a bug that some messages appeared in Dutch
### removed
- nothing
## v1.3.0 ## v1.3.0
### added: ### added:
- now its possible to create 6 tickets instead of 4 - now its possible to create 6 tickets instead of 4
+5 -4
View File
@@ -1,21 +1,22 @@
# config file # config file
[![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) [![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3)
[![version](https://img.shields.io/badge/version-1.3.0%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.0) [![version](https://img.shields.io/badge/version-1.3.2%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.2)
[![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) [![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages)
[![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE)
In this file you find all the information about commands in the config.json file In this file you find all the information about commands in the config.json file
- server_name ➜ the name of your server (optional) _**type: string**_
- server_logo ➜ the logo of your server (optional) _**type: url**_
- bot_name ➜ the name from the bot _**type: string**_ - bot_name ➜ the name from the bot _**type: string**_
- main_color ➜ the color used in embeds _**type: hex color (#000000)**_ - main_color ➜ the color used in embeds _**type: hex color (#000000)**_
- auth_token ➜ your bot's token _**type: string**_ - auth_token ➜ your bot's token _**type: string**_
- botperms_role ➜ this role can do all admin commands from the bot _**type: discord role id**_ - botperms_role ➜ this role can do all admin commands from the bot _**type: discord role id**_
- prefix ➜ the prefix _**type: string**_ - prefix ➜ the prefix _**type: string**_
- logs ➜ enable logs _**type: boolean**_
- credits ➜ disable the credits _**type: boolean**_ - credits ➜ disable the credits _**type: boolean**_
## status: (the status from the bot) ## status: (the status from the bot)
- enabled ➜ enable status _**type: boolean**_
- type ➜ set the status type _**type: string (PLAYING | LISTENING | WATCHING | CUSTOM)** - type ➜ set the status type _**type: string (PLAYING | LISTENING | WATCHING | CUSTOM)**
- text ➜ set the status text _**type: string**_ - text ➜ set the status text _**type: string**_
@@ -64,4 +65,4 @@ I didn't know that open-tickets was going to be so much used. I will be creating
If you have an idea for new updates you can always say it in my discord server! If you have an idea for new updates you can always say it in my discord server!
open-tickets v1.3.0 open-tickets v1.3.2
+26
View File
@@ -0,0 +1,26 @@
# Question & Answer
## How to install node.js 16?
You can install the latest version of node.js on their [website](https://nodejs.org/en/download/). You also need `npm`!
## How to install all the npm packages?
If you installed node.js successful, you can run `npm install` in the command prompt and all the required modules will be installed.
## Where is the config file documentation?
You can find it [here](...)
**How to start the bot?**
If you successfully installed all the npm modules (see above), you can run `npm start`
## Do I need to know discord.js?
Technically not, but it is useful to know if there is an error.
## Why do I get this error?
**Invalid token:**
_Your discord token is not correct, try to look in the config.json file if it's the correct token._
**Privileged intent provided is not enabled or whitelisted:**
_You must enable all the **Gateaway Intents** in the developer panel in the "bot" tab_
### Report other errors to the discord server!
+8 -2
View File
@@ -4,9 +4,15 @@ const intents = discord.Intents
const client = new discord.Client({intents:[intents.FLAGS.GUILDS,intents.FLAGS.GUILD_MESSAGES,intents.FLAGS.GUILD_MEMBERS]}) const client = new discord.Client({intents:[intents.FLAGS.GUILDS,intents.FLAGS.GUILD_MESSAGES,intents.FLAGS.GUILD_MEMBERS]})
exports.client = client exports.client = client
client.on('ready',() => { require("./checker")()
console.log('ready')
client.on('ready',async () => {
const chalk = await (await import("chalk")).default
console.log(chalk.green("open-ticket ready!"))
if (config.logs){chalk.white("\n\nlogs:\n============")}
if (config.status.enabled){
client.user.setActivity(config.status.text,{type:config.status.type}) client.user.setActivity(config.status.text,{type:config.status.type})
}
}) })
var storage = require('./storage/storage') var storage = require('./storage/storage')
+4 -4
View File
@@ -1,16 +1,16 @@
{ {
"name": "safemt-tickets", "name": "open-ticket",
"version": "1.0.0", "version": "1.3.2",
"description": "This is an open-source discord ticket bot, you can configure it and it comes with cool features like a transcript.", "description": "This is an open-source discord ticket bot, you can configure it and it comes with cool features like a transcript.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "", "author": "DJdj Development",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"canvas": "^2.8.0", "chalk": "^5.0.1",
"discord.js": "^13.6.0", "discord.js": "^13.6.0",
"express": "^4.17.1", "express": "^4.17.1",
"node": "^16.10.0", "node": "^16.10.0",