v3.4.0 push 1: fixed all currently known bugs

This commit is contained in:
DJj123dj
2023-04-29 09:15:56 +02:00
parent a6f67a9452
commit fb6b891835
22 changed files with 410 additions and 538 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ Support for Open Ticket is only available for the versions specified below!
| Version | Supported |
| ------- | ------------------ |
| 3.3.3 | :white_check_mark: |
| 3.4.0 | :white_check_mark: |
| 3.3.0 | 🟧 |
| 3.2.2 | 🟧 |
| < 3.2.2 | :x: |
+2 -2
View File
@@ -1,6 +1,6 @@
<img src="https://www.dj-dj.be/wp-content/uploads/2023/02/open-ticket-cropped.png" alt="Open Ticket" width="600px">
[![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-3.3.3-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v3.3.3) [![discord.js](https://img.shields.io/badge/discord.js-v14-CB3837.svg?style=flat-square&logo=npm)]() [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) [![stars](https://img.shields.io/github/stars/djj123dj/open-ticket?color=yellow&label=stars&logo=github&style=flat-square)](https://docs.openticket.dj-dj.be)
[![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-3.4.0-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v3.4.0) [![discord.js](https://img.shields.io/badge/discord.js-v14-CB3837.svg?style=flat-square&logo=npm)]() [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) [![stars](https://img.shields.io/github/stars/djj123dj/open-ticket?color=yellow&label=stars&logo=github&style=flat-square)](https://docs.openticket.dj-dj.be)
### Open Ticket
Open Ticket is of the most customisable discord ticket bots of all time!
@@ -62,7 +62,7 @@ Translators
|Slovenian |n1kkec#5341 |
## links
current version: _v3.3.3_
current version: _v3.4.0_
</br>changelog: [click here](https://docs.openticket.dj-dj.be/other/changelog)
</br>documentation: [click here](https://docs.openticket.dj-dj.be/quick-start)
+6 -15
View File
@@ -23,11 +23,9 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
msg.channel.permissionOverwrites.create(user.id, { ViewChannel:true, AddReactions:true,AttachFiles:true, EmbedLinks:true, SendMessages:true})
msg.channel.send({embeds:[bot.embeds.commands.addEmbed(user,msg.author)]})
@@ -42,8 +40,6 @@ module.exports = () => {
APIEvents.onCommand("add",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.add) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "add") return
@@ -57,11 +53,9 @@ module.exports = () => {
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
interaction.channel.permissionOverwrites.create(user.id, { ViewChannel:true, AddReactions:true,AttachFiles:true, EmbedLinks:true, SendMessages:true})
interaction.editReply({embeds:[bot.embeds.commands.addEmbed(user,interaction.user)]})
@@ -75,7 +69,4 @@ module.exports = () => {
APIEvents.onCommand("add",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+7 -14
View File
@@ -12,7 +12,7 @@ const DISABLE = require("../core/api/api.json").disable
module.exports = () => {
bot.errorLog.log("debug","COMMANDS: loaded change.js")
if (!DISABLE.commands.text.change) client.on("messageCreate",msg => {
if (!DISABLE.commands.text.change) client.on("messageCreate", async msg => {
if (!msg.content.startsWith(config.prefix+"change")) return
if (!msg.guild) return
@@ -21,11 +21,9 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(async msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
const list = []
config.options.forEach((o) => list.push(o.id))
@@ -54,7 +52,6 @@ module.exports = () => {
log("system","ticket type changed",[{key:"user",value:msg.author.tag},{key:"ticket",value:name},{key:"newtype",value:newtype}])
APIEvents.onCommand("change",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.change) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
@@ -67,12 +64,9 @@ module.exports = () => {
}
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(async (msglist) => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
const list = []
config.options.forEach((o) => list.push(o.id))
@@ -121,5 +115,4 @@ module.exports = () => {
log("system","ticket type changed",[{key:"user",value:interaction.user.tag},{key:"ticket",value:name},{key:"newtype",value:newtype}])
APIEvents.onCommand("change",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+15 -20
View File
@@ -26,20 +26,16 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(msglist => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hdraw = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
const hiddendata = hdraw.hiddenData
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
hiddendata.data.push({key:"claimedby",value:claimingUser.id})
hiddendata.push({key:"claimedby",value:claimingUser.id})
bot.hiddenData.writeHiddenData(msg.channel.id,hiddendata)
storage.set("claimData",msg.channel.id,claimingUser.id)
const newEmbed = new embed(firstmsg.embeds[0].data)
.setFooter({text:"claimed by: "+msg.author.tag,iconURL:msg.author.displayAvatarURL()})
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))
if (firstmsg.components[0].components[1] && firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowDisabledNoClaim],embeds:[newEmbed]})
@@ -56,7 +52,6 @@ module.exports = () => {
APIEvents.onTicketClaim(msg.author,loguser,msg.channel,msg.guild,new Date(),{status:"open",name:msg.channel.name,ticketOptions:ticketData})
APIEvents.onCommand("claim",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.claim) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
@@ -71,26 +66,27 @@ module.exports = () => {
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(msglist => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hdraw = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
const hiddendata = hdraw.hiddenData
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
hiddendata.data.push({key:"claimedby",value:user.id})
hiddendata.push({key:"claimedby",value:user.id})
bot.hiddenData.writeHiddenData(interaction.channel.id,hiddendata)
storage.set("claimData",interaction.channel.id,user.id)
interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const newEmbed = new embed(firstmsg.embeds[0].data)
.setFooter({text:"claimed by: "+user.tag,iconURL:user.displayAvatarURL()})
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))
if (firstmsg.components[0].components[1] && firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowDisabledNoClaim],embeds:[newEmbed]})
}else{
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowNormalNoClaim],embeds:[newEmbed]})
}
})
interaction.editReply({embeds:[bot.embeds.commands.claimEmbed(user,interaction.user)]})
@@ -101,5 +97,4 @@ module.exports = () => {
APIEvents.onTicketClaim(interaction.user,user,interaction.channel,interaction.guild,new Date(),{status:"open",name:interaction.channel.name,ticketOptions:ticketData})
APIEvents.onCommand("claim",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+8 -17
View File
@@ -24,13 +24,11 @@ module.exports = () => {
}
const reason = tempreason
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
if (hiddendata.data.find(h => h.key == "pendingdelete")) return msg.channel.send({embeds:[bot.errorLog.warning("Warning!","You can't close a ticket while it's being deleted!")]})
if (hiddendata.find(h => h.key == "pendingdelete")) return msg.channel.send({embeds:[bot.errorLog.warning("Warning!","You can't close a ticket while it's being deleted!")]})
const descriptionReason = reason ? "**"+l.messages.reason+":** "+reason : false
msg.channel.send({embeds:[bot.embeds.commands.closeEmbed(msg.author,descriptionReason)],components:[bot.buttons.close.closeCommandRow]})
@@ -51,9 +49,6 @@ module.exports = () => {
})
})
if (!DISABLE.commands.slash.close) client.on("interactionCreate",async(interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "close") return
@@ -64,13 +59,11 @@ module.exports = () => {
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
if (hiddendata.data.find(h => h.key == "pendingdelete")) return interaction.editReply({embeds:[bot.errorLog.warning("Warning!","You can't close a ticket while it's being deleted!")]})
if (hiddendata.find(h => h.key == "pendingdelete")) return interaction.editReply({embeds:[bot.errorLog.warning("Warning!","You can't close a ticket while it's being deleted!")]})
const descriptionReason = reason ? "**"+l.messages.reason+":** "+reason : false
interaction.editReply({embeds:[bot.embeds.commands.closeEmbed(interaction.user,descriptionReason)],components:[bot.buttons.close.closeCommandRow]})
@@ -88,7 +81,5 @@ module.exports = () => {
log("command","someone used the 'close' command",[{key:"user",value:interaction.user.tag}])
APIEvents.onCommand("close",true,interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+6 -14
View File
@@ -21,11 +21,9 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
msg.channel.send({embeds:[bot.embeds.commands.deleteEmbed(msg.author)]})
@@ -42,8 +40,6 @@ module.exports = () => {
log("command","someone used the 'delete' command",[{key:"user",value:msg.author.tag}])
APIEvents.onCommand("delete",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
@@ -59,11 +55,9 @@ module.exports = () => {
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
interaction.editReply({embeds:[bot.embeds.commands.deleteEmbed(interaction.user)]})
@@ -80,7 +74,5 @@ module.exports = () => {
log("command","someone used the 'delete' command",[{key:"user",value:interaction.user.tag}])
APIEvents.onCommand("delete",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+6 -13
View File
@@ -23,11 +23,9 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
msg.channel.permissionOverwrites.delete(user.id)
msg.channel.send({embeds:[bot.embeds.commands.removeEmbed(user,msg.author)]})
@@ -42,8 +40,6 @@ module.exports = () => {
APIEvents.onCommand("remove",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.remove) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "remove") return
@@ -57,11 +53,9 @@ module.exports = () => {
await interaction.deferReply()
await interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
interaction.channel.permissionOverwrites.delete(user.id)
interaction.editReply({embeds:[bot.embeds.commands.removeEmbed(user,interaction.user)]})
@@ -75,5 +69,4 @@ module.exports = () => {
APIEvents.onTicketRemove(interaction.user,loguser,interaction.channel,interaction.guild,new Date(),{status:"open",name:interaction.channel.name,ticketOptions:ticketData})
APIEvents.onCommand("remove",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+6 -14
View File
@@ -21,11 +21,9 @@ module.exports = () => {
return
}
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
var newname = msg.content.split(config.prefix+"rename")[1].substring(1)
@@ -50,9 +48,6 @@ module.exports = () => {
APIEvents.onCommand("rename",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.rename) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "rename") return
@@ -65,11 +60,9 @@ module.exports = () => {
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
var newname = interaction.options.getString("name")
var name = interaction.channel.name
@@ -91,5 +84,4 @@ module.exports = () => {
APIEvents.onCommand("rename",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+7 -16
View File
@@ -15,13 +15,11 @@ module.exports = () => {
if (!DISABLE.commands.text.reopen) client.on("messageCreate",msg => {
if (!msg.content.startsWith(config.prefix+"reopen")) return
msg.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
if (hiddendata.data.find(h => h.key == "pendingdelete")) return msg.channel.send({embeds:[bot.errorLog.warning("Warning!","You can't re-open a ticket while it's being deleted!")]})
if (hiddendata.find(h => h.key == "pendingdelete")) return msg.channel.send({embeds:[bot.errorLog.warning("Warning!","You can't re-open a ticket while it's being deleted!")]})
msg.channel.send({embeds:[bot.embeds.commands.reopenEmbed(msg.author)],components:[bot.buttons.close.openRowNormal]})
@@ -31,19 +29,15 @@ module.exports = () => {
APIEvents.onCommand("reopen",true,msg.author,msg.channel,msg.guild,new Date())
})
})
if (!DISABLE.commands.slash.reopen) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "reopen") return
await interaction.deferReply()
interaction.channel.messages.fetchPinned().then(async msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
if (hiddendata.data.find(h => h.key == "pendingdelete")) return interaction.editReply({embeds:[bot.errorLog.warning("Warning!","You can't re-open a ticket while it's being deleted!")]})
@@ -54,7 +48,4 @@ module.exports = () => {
log("command","someone used the 'reopen' command",[{key:"user",value:interaction.user.tag}])
APIEvents.onCommand("reopen",true,interaction.user,interaction.channel,interaction.guild,new Date())
})
})
}
+15 -14
View File
@@ -26,19 +26,20 @@ module.exports = () => {
const unclaimuser = storage.get("claimData",msg.channel.id)
if (!unclaimuser || unclaimuser == "false") return msg.channel.send({embeds:[bot.errorLog.serverError("This ticket isn't claimed yet!")]})
const hiddendata = bot.hiddenData.readHiddenData(msg.channel.id)
if (hiddendata.length < 1) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
hiddendata.push({key:"claimedby",value:"false"})
bot.hiddenData.writeHiddenData(msg.channel.id,hiddendata)
storage.set("claimData",msg.channel.id,"false")
msg.channel.messages.fetchPinned().then(msglist => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]})
const hdraw = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
const hiddendata = hdraw.hiddenData
const ticketId = hiddendata.data.find(d => d.key == "type").value
hiddendata.data.push({key:"claimedby",value:"false"})
storage.set("claimData",msg.channel.id,"false")
const newEmbed = new embed(firstmsg.embeds[0].data)
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))
const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true)
if (ticketData && ticketData.autoclose.enable){
@@ -81,20 +82,20 @@ module.exports = () => {
const unclaimuser = storage.get("claimData",interaction.channel.id)
if (!unclaimuser || unclaimuser == "false") return interaction.editReply({embeds:[bot.errorLog.serverError("This ticket isn't claimed yet!")]})
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
hiddendata.push({key:"claimedby",value:"false"})
bot.hiddenData.writeHiddenData(interaction.channel.id,hiddendata)
storage.set("claimData",interaction.channel.id,"false")
interaction.channel.messages.fetchPinned().then(msglist => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hdraw = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
const hiddendata = hdraw.hiddenData
const ticketId = hiddendata.data.find(d => d.key == "type").value
hiddendata.data.push({key:"claimedby",value:"false"})
storage.set("claimData",interaction.channel.id,"false")
const newEmbed = new embed(firstmsg.embeds[0].data)
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))
const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true)
if (ticketData && ticketData.autoclose.enable){
+1 -1
View File
@@ -102,7 +102,7 @@
"dropdown":false,
"enableFooter":false,
"footer":"Open Ticket v3.3.3 - I'm a footer!",
"footer":"Open Ticket v3.4.0 - I'm a footer!",
"enableFooterImage":false,
"footerImage":"https://www.example.com/catmemes/cat.png",
@@ -7,7 +7,6 @@ const log = bot.errorLog.log
const permissionChecker = require("../../../utils/permisssionChecker")
const storage = bot.storage
const hiddendata = bot.hiddenData
const embed = discord.EmbedBuilder
const mc = config.color
const permsChecker = require("../../../utils/permisssionChecker")
@@ -32,20 +31,21 @@ module.exports = () => {
return
}
const hiddendata = bot.hiddenData.readHiddenData(interaction.channel.id)
if (hiddendata.length < 1) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
hiddendata.push({key:"claimedby",value:interaction.user.id})
bot.hiddenData.writeHiddenData(interaction.channel.id,hiddendata)
storage.set("claimData",interaction.channel.id,interaction.user.id)
interaction.channel.messages.fetchPinned().then(msglist => {
/**@type {discord.Message} */
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.editReply({embeds:[bot.errorLog.notInATicket]})
const hdraw = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
const hiddendata = hdraw.hiddenData
const ticketId = hiddendata.data.find(d => d.key == "type").value
hiddendata.data.push({key:"claimedby",value:interaction.user.id})
storage.set("claimData",interaction.channel.id,interaction.user.id)
const newEmbed = new embed(firstmsg.embeds[0].data)
.setFooter({text:"claimed by: "+interaction.user.tag,iconURL:interaction.user.displayAvatarURL()})
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))
if (firstmsg.components[0].components[1] && firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowDisabledNoClaim],embeds:[newEmbed]})
+14 -51
View File
@@ -73,26 +73,16 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
if (Number(storage.get("amountOfUserTickets",getuserID)) < 0) storage.set("amountOfUserTickets",getuserID,0)
//getID & send DM & send api event
await channel.messages.fetchPinned().then(async msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return false
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value.value
const hiddendata = bot.hiddenData.readHiddenData(channel.id)
if (hiddendata.length < 1) return channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
const ticketData = require("../utils/configParser").getTicketById(ticketId,true)
require("../api/modules/events").onTicketDelete(user,channel,guild,new Date(),{name:channel.name,status:"deleted",ticketOptions:ticketData})
const id = hiddendata.data.find(d => d.key == "openerid").value
const sphd = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description)
sphd.hiddenData.data.push({key:"pendingdelete",value:"true"})
const newEmbed = new discord.EmbedBuilder(firstmsg.embeds[0].data)
newEmbed.setDescription(sphd.description + bot.hiddenData.writeHiddenData(sphd.hiddenData.type,sphd.hiddenData.data))
await firstmsg.edit({embeds:[newEmbed]})
if (!id) return false
})
hiddendata.push({key:"pendingdelete",value:"true"})
bot.hiddenData.writeHiddenData(channel.id,hiddendata)
}else if (mode == "close"){
//close
@@ -143,23 +133,13 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
const ticketInfoError = bot.errorLog.serverError("Unable to detect ticket information.\n*(First message that this bot sends)*\n\n__**Possible reasons:**__\n- you unpinned the first message\n- the first message is deleted\n- it has been unpinned & repinned after another message has been pinned.\n\n__**Possible solutions:**__\n- unpin all messages in this channel & repin the first message that this bot sent.\nIf this doesn't work, just delete the ticket manually!")
//add ticket adminroles
await channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
var firstmsg = msglist.find((m => m.author.id == client.user.id))
if (firstmsg == undefined || firstmsg.author.id != client.user.id){
return channel.send({embeds:[ticketInfoError]})
}
}
if (firstmsg.embeds.length < 1 || !firstmsg.embeds[0].description.includes("OTDATA")) return channel.send({embeds:[ticketInfoError]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const hiddendata = bot.hiddenData.readHiddenData(channel.id)
if (hiddendata.length < 1) return channel.send({embeds:[bot.errorLog.notInATicket]})
const ticketId = hiddendata.find(d => d.key == "type").value
const ticketData = require("../utils/configParser").getTicketById(ticketId,true)
if (!ticketData) return
if (ticketData.closedCategory.enable){
/**@type {discord.CategoryChannel} */
const category = guild.channels.cache.find(c => c.id == ticketData.closedCategory.id && c.type == discord.ChannelType.GuildCategory)
@@ -170,11 +150,7 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
}
}
/**
* @type {String[]}
*/
const ticketadmin = ticketData.adminroles
ticketadmin.forEach((role,index) => {
ticketData.adminroles.forEach((role,index) => {
if (!config.adminRoles.includes(role)){
try {
const adminrole = guild.roles.cache.find(r => r.id == role)
@@ -191,7 +167,6 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
}
}
})
})
channel.permissionOverwrites.set(permissionArray)
@@ -207,23 +182,8 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
log("system","closed a ticket",[{key:"user",value:user.tag},{key:"ticket",value:channel.name}])
//getID & send DM & send api event
await channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return false
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value
const ticketData = require("../utils/configParser").getTicketById(ticketId,true)
//send api event
require("../api/modules/events").onTicketClose(user,channel,guild,new Date(),{name:channel.name,status:"closed",ticketOptions:ticketData},newReason)
const id = hiddendata.data.find(d => d.key == "openerid").value
if (!id) return false
})
}
/**
@@ -263,6 +223,9 @@ exports.closeManager = async (member,channel,prefix,mode,reason,nomessage) => {
const deleteHandler = async () => {
if (deleteRequired){
pendingDelete.shift()
//delete HIDDENDATA
storage.delete("HIDDENDATA",channel.id)
await channel.delete()
}
}
+5 -9
View File
@@ -132,11 +132,8 @@ module.exports = () => {
})
//add ticket adminroles
/**
* @type {String[]}
*/
const readonlyTicketadmin = currentTicketOptions.readonlyAdminroles
readonlyTicketadmin.forEach((role,index) => {
if (currentTicketOptions.readonlyAdminroles){
currentTicketOptions.readonlyAdminroles.forEach((role,index) => {
if (!config.adminRoles.includes(role) && !currentTicketOptions.adminroles.includes(role)){
try {
const adminrole = guild.roles.cache.find(r => r.id == role)
@@ -151,6 +148,7 @@ module.exports = () => {
}catch{}
}
})
}
//add member role
if (config.system.memberRole && ![" ","0","false","null","undefined"].includes(config.system.memberRole)){
@@ -178,7 +176,7 @@ module.exports = () => {
storage.set("userFromChannel",ticketChannel.id,interaction.member.id)
if (currentTicketOptions.autoclose.enable) storage.set("autocloseTickets",ticketChannel.id,currentTicketOptions.autoclose.inactiveHours)
const hiddendata = bot.hiddenData.writeHiddenData("ticketdata",[{key:"type",value:currentTicketOptions.id},{key:"openerid",value:interaction.user.id},{key:"createdms",value:new Date().getTime()}])
bot.hiddenData.writeHiddenData(ticketChannel.id,[{key:"type",value:currentTicketOptions.id},{key:"openerid",value:interaction.user.id},{key:"createdms",value:new Date().getTime()}])
var ticketEmbed = new discord.EmbedBuilder()
//.setAuthor({name:interaction.user.id})
@@ -191,9 +189,7 @@ module.exports = () => {
}
if (currentTicketOptions.ticketmessage.length > 0){
ticketEmbed.setDescription(currentTicketOptions.ticketmessage+hiddendata)
}else{
ticketEmbed.setDescription(hiddendata)
ticketEmbed.setDescription(currentTicketOptions.ticketmessage)
}
if (currentTicketOptions.thumbnail.enable) ticketEmbed.setThumbnail(currentTicketOptions.thumbnail.url)
@@ -46,13 +46,9 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
})
msg.embeds.forEach((embed) => {
if (embed.description){
var desc = bot.hiddenData.removeHiddenData(embed.description).description
}else{var desc = false}
embedArray.push({
title:embed.title || false,
description:desc,
description:embed.description ? embed.description : false,
authorimg:((embed.author && embed.author.iconURL) ? embed.author.iconURL : false),
authortext:(embed.author ? embed.author.name : false),
footerimg:((embed.footer && embed.footer.iconURL) ? embed.footer.iconURL : false),
@@ -1,6 +1,6 @@
{
"version":"1.0.0",
"otversion":"3.3.3",
"otversion":"3.4.0",
"style":{
"enableCustomBackground":false,
"backgroundModus":"color OR image",
+8 -10
View File
@@ -36,16 +36,14 @@ module.exports = async (messages,guild,channel,user,reason) => {
const chName = channel.name
const chId = channel.id
/**@param {discord.Collection<string, discord.Message<true>>} msglist*/
const asyncmanager = async (msglist) => {
var firstmsg = msglist.last()
const asyncmanager = async () => {
const hiddendata = bot.hiddenData.readHiddenData(channel.id)
if (hiddendata.length < 1) return
const ticketId = hiddendata.find(d => d.key == "type").value
const ticketData = require("../utils/configParser").getTicketById(ticketId,true)
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return false
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type")
const id = hiddendata.data.find(d => d.key == "openerid").value
const opentime = new Date(Number(hiddendata.data.find(d => d.key == "createdms").value))
const id = hiddendata.find(d => d.key == "openerid").value
const opentime = new Date(Number(hiddendata.find(d => d.key == "createdms").value))
const ticketopener = client.users.cache.find(u => u.id == id)
@@ -148,5 +146,5 @@ module.exports = async (messages,guild,channel,user,reason) => {
}
}
}
asyncmanager(msglist)
asyncmanager()
}
+29 -48
View File
@@ -1,68 +1,49 @@
const storage = require("../../index").storage
/**@typedef {{type:String,data:[{key:String,value:String}],status:Boolean}} hiddenData */
/**@typedef {[{key:String,value:String}]} hiddenData */
/**
*
* @param {String} messageContent
* @param {String} channelid
* @returns {hiddenData}
*/
exports.readHiddenData = (messageContent) => {
//ticketdata//type:123|userid:456)
if (!messageContent.includes("[ ](https://OTDATA|")) return {type:"",data:[],status:false}
const rawhidden = messageContent.split("[ ](https://OTDATA|")[1]
const rawhidden2 = rawhidden.split("//")
exports.readHiddenData = (channelid) => {
const content = storage.get("HIDDENDATA",channelid)
if (!content) return {type:"",data:[],status:false}
const datatype = rawhidden2[0]
var rawhiddendata = rawhidden2[1]
var rawhiddendataArray = rawhiddendata.split("")
rawhiddendataArray.pop()
rawhiddendata = rawhiddendataArray.join("")
const splittedData = rawhiddendata.split("|")
const resultData = []
splittedData.forEach((data) => {
// type:123
const dataresult = data.split(":")
resultData.push({key:dataresult[0],value:dataresult[1]})
})
return {type:datatype,data:resultData,status:true}
try {
return JSON.parse(content)
} catch {
return []
}
}
/**
*
* @param {String} type
* @param {String} channelid
* @param {[{key:String,value:String}]} data
* @returns {String}
* @returns {Boolean}
*/
exports.writeHiddenData = (type,data) => {
const dataValues = []
data.forEach((d) => {
dataValues.push(d.key+":"+d.value)
})
const datastring = dataValues.join("|")
const result = "[ ](https://OTDATA|"+type+"//"+datastring+")"
return result
exports.writeHiddenData = (channelid,data) => {
try {
storage.set("HIDDENDATA",channelid,JSON.stringify(data))
return true
} catch {
return false
}
}
/**
*
* @param {String} description
* @returns {{description:String,hiddenData:hiddenData}}
* @param {String} channelid
* @returns {Boolean}
*/
exports.removeHiddenData = (description) => {
if (!description.includes("[ ](https://OTDATA|")) return {description:description,hiddenData:[]}
const hiddenData = this.readHiddenData(description)
const splitted = description.split("[ ](https://OTDATA")
const original = splitted[0]
return {description:original,hiddenData:hiddenData}
exports.deleteHiddenData = (channelid) => {
try {
storage.delete("HIDDENDATA",channelid)
return true
} catch {
return false
}
}
+1 -1
View File
@@ -28,7 +28,7 @@
INFORMATION:
============
Open Ticket v3.3.3 - © DJdj Development
Open Ticket v3.4.0 - © DJdj Development
discord: https://discord.dj-dj.be
website: https://www.dj-dj.be
+1 -1
View File
@@ -36,7 +36,7 @@
"goToTicket":"Geh zu deinem Ticket",
"ticketWarning":"Die Einbettung befindet sich in der Nachricht unten!",
"maxTicketWarning":"**Warnung:** _Sie können nur {0} ticket(s) erstellen zu einer Zeit!_"
"maxTicketWarning":"**Warnung:** _Es können maximal {0} Tickets zur gleichen Zeit geöffnet sein!_"
},
"helpMenu":{
"title":"Hilfe Menu:",
+2 -3
View File
@@ -1,6 +1,6 @@
{
"name": "open-ticket",
"version": "3.3.3",
"version": "3.4.0",
"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",
"scripts": {
@@ -15,8 +15,7 @@
"dependencies": {
"axios": "^0.27.2",
"chalk": "^5.0.1",
"discord.js": "^14.8.0",
"node": "^16.10.0"
"discord.js": "^14.9.0"
},
"repository": {
"type": "git",