3.0 public beta 2
This commit is contained in:
@@ -26,6 +26,7 @@ This is an open-source discord ticket bot, you can configure it and it comes wit
|
|||||||
- t0miiis
|
- t0miiis
|
||||||
- josuens14
|
- josuens14
|
||||||
- M4
|
- M4
|
||||||
|
- David.
|
||||||
|
|
||||||
## features
|
## features
|
||||||
- discord interaction buttons
|
- discord interaction buttons
|
||||||
|
|||||||
+4
-1
@@ -42,7 +42,10 @@
|
|||||||
"category":"category id",
|
"category":"category id",
|
||||||
"message":"You created a ticket!",
|
"message":"You created a ticket!",
|
||||||
"enableDmOnOpen":true,
|
"enableDmOnOpen":true,
|
||||||
"ticketmessage":"The staff will help you soon!\n\n*Click on the button below to close the ticket!*"
|
"ticketmessage":"The staff will help you soon!\n\n*Click on the button below to close the ticket!*",
|
||||||
|
|
||||||
|
"enableThumbnail":false,
|
||||||
|
"thumbnailUrl":"https://www.example.com/catmemes/cat.png"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+80
-8
@@ -52,9 +52,10 @@ exports.checker = async () => {
|
|||||||
}
|
}
|
||||||
/**@param {String} value */
|
/**@param {String} value */
|
||||||
const checkToken = (value) => {
|
const checkToken = (value) => {
|
||||||
if (value.includes(" ") || value.length < 40){
|
if (value.length < 40){
|
||||||
createError("'auth_token' | your token is invalid")
|
createError("'auth_token' | your token is invalid")
|
||||||
}
|
}
|
||||||
|
if (value.includes(" ")) createError("'auth_token' | your token includes spaces!")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@param {String} value @param {String} path */
|
/**@param {String} value @param {String} path */
|
||||||
@@ -133,8 +134,12 @@ exports.checker = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getButtonClass = require("./utils/getButton").rawButtonData
|
const configParser = require("./utils/configParser")
|
||||||
/**@param {getButtonClass} option */
|
/**
|
||||||
|
* @param {configParser.OTAllOptions} option
|
||||||
|
* @param {String} path
|
||||||
|
*/
|
||||||
|
|
||||||
const checkOption = (option,path) => {
|
const checkOption = (option,path) => {
|
||||||
|
|
||||||
//id
|
//id
|
||||||
@@ -219,13 +224,13 @@ exports.checker = async () => {
|
|||||||
createWarn("'"+path+"/url' | a url can't contain spaces")
|
createWarn("'"+path+"/url' | a url can't contain spaces")
|
||||||
}
|
}
|
||||||
if (option.url.length < 1){
|
if (option.url.length < 1){
|
||||||
createError("'"+path+"/url' | you have no url in this button")
|
createError("'"+path+"/url' | there is no url!")
|
||||||
}
|
}
|
||||||
if (!option.url.startsWith("https://") && !option.url.startsWith("http://") && !option.url.startsWith("discord://")){
|
if (!option.url.startsWith("https://") && !option.url.startsWith("http://") && !option.url.startsWith("discord://")){
|
||||||
createWarn("'"+path+"/url' | your url doesn't start with https or http!")
|
createWarn("'"+path+"/url' | your url doesn't start with https or http!")
|
||||||
}
|
}
|
||||||
if (option.url.startsWith("http://")){
|
if (option.url.startsWith("http://")){
|
||||||
createWarn("'"+path+"/url' | your url is not a HTTPS link! discord maybe blocks this url!")
|
createWarn("'"+path+"/url' | your url is not a HTTPS link! discord can block this url!")
|
||||||
}
|
}
|
||||||
}else if (type == "role"){
|
}else if (type == "role"){
|
||||||
//color
|
//color
|
||||||
@@ -246,8 +251,69 @@ exports.checker = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {configParser.OTConfigMessage} input
|
||||||
|
* @param {String} path
|
||||||
|
*/
|
||||||
const checkMessage = (input,path) => {
|
const checkMessage = (input,path) => {
|
||||||
|
//id
|
||||||
|
if (!input.id) createError("'"+path+"/id' | this embed doesn't have an id!")
|
||||||
|
if (input.id.length > 50) createError("'"+path+"/id' | the id can't be longer than 50")
|
||||||
|
if (input.id.includes(" ") || input.id.includes("\n")) createError("'"+path+"/id' | the id can't contain spaces!")
|
||||||
|
|
||||||
|
//name
|
||||||
|
if (input.name.length < 1){
|
||||||
|
createWarn("'"+path+"/name' | this embed has no name!")
|
||||||
|
}else if (input.name.length > 99) {
|
||||||
|
createError("'"+path+"/name' | the name can't be longer than 100")
|
||||||
|
}
|
||||||
|
|
||||||
|
//description
|
||||||
|
if (input.description.length < 0){
|
||||||
|
createWarn("'"+path+"/description' | this embed doesn't have a description!")
|
||||||
|
}
|
||||||
|
|
||||||
|
//dropdown
|
||||||
|
checkType(input.dropdown,"boolean",path+"/dropdown")
|
||||||
|
|
||||||
|
//footer
|
||||||
|
checkType(input.enableFooter,"boolean",path+"/enableFooter")
|
||||||
|
if (input.enableFooter){
|
||||||
|
if (input.footer.length < 1) createError("'"+path+"/footer' | no footer!")
|
||||||
|
if (input.footer.length > 200) createError("'"+path+"/footer' | footer length can't be more than 200!")
|
||||||
|
}
|
||||||
|
|
||||||
|
//thumbnail
|
||||||
|
checkType(input.enableThumbnail,"boolean",path+"/enableThumbnail")
|
||||||
|
if (input.enableThumbnail){
|
||||||
|
if (input.thumbnail.length < 1) createError("'"+path+"/thumbnail' | no thumbnail url!")
|
||||||
|
}
|
||||||
|
|
||||||
|
//customColor
|
||||||
|
checkType(input.enableCustomColor,"boolean",path+"/enableCustomColor")
|
||||||
|
if (input.enableCustomColor){
|
||||||
|
if (input.color.length < 1) createError("'"+path+"/color' | no color!")
|
||||||
|
checkHexColor(input.color,path+"/color")
|
||||||
|
}
|
||||||
|
|
||||||
|
//ticket explaination & max tickets warning
|
||||||
|
checkType(input.enableTicketExplaination,"boolean",path+"/enableTicketExplaination")
|
||||||
|
checkType(input.enableMaxTicketsWarning,"boolean",path+"/enableMaxTicketsWarning")
|
||||||
|
|
||||||
|
//OPTIONS!!!
|
||||||
|
var counter = 0
|
||||||
|
input.options.forEach((option) => {if (!configParser.optionExists(option)){counter++}})
|
||||||
|
|
||||||
|
if (counter == input.options.length){
|
||||||
|
createWarn("'"+path+"/options' | insert the option ids here!")
|
||||||
|
}else{
|
||||||
|
input.options.forEach((option,index) => {
|
||||||
|
if (!configParser.optionExists(option)){
|
||||||
|
createWarn("'"+path+"/options:"+index+"' | this option doesnt exist!")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------|
|
//--------------------------|
|
||||||
@@ -281,11 +347,12 @@ exports.checker = async () => {
|
|||||||
checkType(config.status.enabled,"boolean","status/enabled")
|
checkType(config.status.enabled,"boolean","status/enabled")
|
||||||
if (config.status.enabled){
|
if (config.status.enabled){
|
||||||
if (config.status.type != "PLAYING" && config.status.type != "LISTENING" && config.status.type != "WATCHING"){
|
if (config.status.type != "PLAYING" && config.status.type != "LISTENING" && config.status.type != "WATCHING"){
|
||||||
createError("'status/type' | not a valid status type!")
|
createError("'status/type' | not a valid status type! (LISTENING,WATCHING,PLAYING)")
|
||||||
}
|
}
|
||||||
if (config.status.text.length < 1 || config.status.text.length > 40){
|
if (config.status.text.length < 1){
|
||||||
createError("'status/text' | text too long or short!")
|
createError("'status/text' | there is no status text!")
|
||||||
}
|
}
|
||||||
|
if (config.status.text.length > 50) createError("'status/text' | text too long!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,6 +387,11 @@ exports.checker = async () => {
|
|||||||
checkOption(option,"options/"+index)
|
checkOption(option,"options/"+index)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//messages
|
||||||
|
config.messages.forEach((message,index) => {
|
||||||
|
checkMessage(message,"messages/"+index)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
//discord check
|
//discord check
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ module.exports = () => {
|
|||||||
ticketEmbed.setDescription(hiddendata)
|
ticketEmbed.setDescription(hiddendata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentTicketOptions.enableThumbnail) ticketEmbed.setThumbnail(currentTicketOptions.thumbnailUrl)
|
||||||
|
|
||||||
ticketChannel.send({
|
ticketChannel.send({
|
||||||
content:"<@"+interaction.member.id+"> @here",
|
content:"<@"+interaction.member.id+"> @here",
|
||||||
embeds:[ticketEmbed],
|
embeds:[ticketEmbed],
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const l = bot.language
|
|||||||
//==================
|
//==================
|
||||||
|
|
||||||
//OTTicketOptions
|
//OTTicketOptions
|
||||||
/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color: String,adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String}} OTTicketOptions */
|
/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color: "red"|"green"|"blue"|"gray",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, enableThumbnail:Boolean, thumbnailUrl:String}} OTTicketOptions */
|
||||||
|
|
||||||
//OTRoleOptions
|
//OTRoleOptions
|
||||||
/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",enableDmOnOpen:Boolean}} OTRoleOptions */
|
/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",enableDmOnOpen:Boolean}} OTRoleOptions */
|
||||||
@@ -19,7 +19,7 @@ const l = bot.language
|
|||||||
/**@typedef {{id: string, name: string, description: string, dropdown: boolean, enableFooter: boolean, footer: string, enableThumbnail: boolean, thumbnail: string, enableCustomColor: boolean, color: string, options: string[], enableTicketExplaination: boolean, enableMaxTicketsWarning: boolean}} OTConfigMessage*/
|
/**@typedef {{id: string, name: string, description: string, dropdown: boolean, enableFooter: boolean, footer: string, enableThumbnail: boolean, thumbnail: string, enableCustomColor: boolean, color: string, options: string[], enableTicketExplaination: boolean, enableMaxTicketsWarning: boolean}} OTConfigMessage*/
|
||||||
|
|
||||||
//StringOptions
|
//StringOptions
|
||||||
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDmOnOpen"|"ticketmessage"} OTTicketStringOptions */
|
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDmOnOpen"|"ticketmessage"|"enableThumbnail"|"thumbnailUrl"} OTTicketStringOptions */
|
||||||
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDmOnOpen"} OTRoleStringOptions */
|
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDmOnOpen"} OTRoleStringOptions */
|
||||||
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"url"} OTWebsiteStringOptions */
|
/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"url"} OTWebsiteStringOptions */
|
||||||
|
|
||||||
@@ -154,3 +154,34 @@ exports.getTicketValuesArray = (value,idWithoutOTnewT) => {
|
|||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**@type {OTTicketOptions} */
|
||||||
|
this.ticketType = {}
|
||||||
|
|
||||||
|
/**@type {OTRoleOptions} */
|
||||||
|
this.roleType = {}
|
||||||
|
|
||||||
|
/**@type {OTWebsiteOptions} */
|
||||||
|
this.websiteType = {}
|
||||||
|
|
||||||
|
/**@type {OTConfigMessage} */
|
||||||
|
this.messageType = {}
|
||||||
|
|
||||||
|
|
||||||
|
//OTAllOptions
|
||||||
|
/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, enableThumbnail:Boolean, thumbnailUrl:String,url:String}} OTAllOptions */
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {String} id
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
exports.optionExists = (id) => {
|
||||||
|
var result = false
|
||||||
|
config.options.forEach((option) => {
|
||||||
|
if (option.id == id){
|
||||||
|
result = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -60,7 +60,8 @@ exports.createEmbed = (id) => {
|
|||||||
description = description+"\n\n"+l.commands.maxTicketWarning.replace("{0}",config.system.max_allowed_tickets)
|
description = description+"\n\n"+l.commands.maxTicketWarning.replace("{0}",config.system.max_allowed_tickets)
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.setDescription(description)
|
if (description) embed.setDescription(description)
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user