Skip to content

Commit

Permalink
Open Ticket v3.3!
Browse files Browse the repository at this point in the history
Open Ticket v3.3!
  • Loading branch information
DJj123dj authored Mar 19, 2023
2 parents d0bcf26 + 4dced81 commit 94ee890
Show file tree
Hide file tree
Showing 66 changed files with 1,556 additions and 499 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.2.2-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v3.2.2) [![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.3.0-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v3.3.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!
Expand All @@ -13,7 +13,7 @@ Take a look at all the features and discover the possibilities!
## Features
- **🎉 NEW! html transcripts!**
- 🔒 close, ❌ delete & ✅ re-open tickets
- 🇬🇧 translation in 12 different languages
- 🇬🇧 translation in 14 different languages
- 📄 very advanced customisation
- 🆗 buttons or 🔽 dropdowns!
- 🆒 plugins
Expand Down Expand Up @@ -57,9 +57,11 @@ Translators
|Danish |the_gamer#5095 |
|Portuguese |QuirAddon#9778 |
|Russian |Apexo#0723 |
|Turkish |Hydrâelčhâvø#1575 |
|Polish |MKevas#8311 |

## links
current version: _v3.2.2_
current version: _v3.3.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)

Expand Down
8 changes: 5 additions & 3 deletions commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = () => {

})

if (!DISABLE.commands.slash.add) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.add) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "add") return
const user = interaction.options.getUser("user")
Expand All @@ -55,14 +55,16 @@ module.exports = () => {
return
}

await interaction.deferReply()

interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
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

interaction.channel.permissionOverwrites.create(user.id, { ViewChannel:true, AddReactions:true,AttachFiles:true, EmbedLinks:true, SendMessages:true})
interaction.reply({embeds:[bot.embeds.commands.addEmbed(user,interaction.user)]})
interaction.editReply({embeds:[bot.embeds.commands.addEmbed(user,interaction.user)]})

var loguser = user
log("command","someone used the 'add' command",[{key:"user",value:interaction.user.tag}])
Expand Down
51 changes: 37 additions & 14 deletions commands/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ module.exports = () => {
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
const ticketId = hiddendata.data.find(d => d.key == "type").value

const list = []
config.options.forEach((o) => list.push(o.id))

var newtype = msg.content.split(config.prefix+"change")[1].substring(1)
if (!newtype) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage(l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})
if (!newtype) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(list,l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})

const newTicket = require("../core/utils/configParser").getTicketById(newtype)
const list = []
config.options.forEach((o) => list.push(o.id))
if (!newTicket) return bot.errorLog.invalidIdChooseFromList(list)
if (!newTicket) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(list,l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})

/**@type {String} */
var chName = msg.channel.name
Expand All @@ -55,7 +56,7 @@ module.exports = () => {
})
})

if (!DISABLE.commands.slash.change) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.change) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "change") return

Expand All @@ -65,21 +66,26 @@ module.exports = () => {
return
}

//interaction.deferReply()
interaction.channel.messages.fetchPinned().then(async msglist => {
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.reply({embeds:[bot.errorLog.notInATicket]})
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

var newtype = interaction.options.getString("type",true)
if (!newtype) return interaction.reply({embeds:[bot.errorLog.invalidArgsMessage(l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})

const newTicket = require("../core/utils/configParser").getTicketById(newtype,true)
const list = []
config.options.forEach((o) => list.push(o.id))
if (!newTicket) return bot.errorLog.invalidIdChooseFromList(list)

var newtype = interaction.options.getString("type",true)
const newTicket = require("../core/utils/configParser").getTicketById(newtype,true)

if (!newTicket) return interaction.editReply({embeds:[bot.errorLog.invalidIdChooseFromList(list,l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})

/**@type {discord.PermissionOverwriteManager} */
const prePermsManager = interaction.channel.permissionOverwrites
const prePerms = prePermsManager.cache

/**@type {String} */
var chName = interaction.channel.name
const splitted = chName.split("-")
Expand All @@ -91,8 +97,25 @@ module.exports = () => {
if (parent && parent.type == discord.ChannelType.GuildCategory) interaction.channel.setParent(parent)
}

await prePermsManager.set(prePerms)
interaction.channel.setName(newTicket.channelprefix+name)
interaction.reply({embeds:[bot.embeds.commands.changeEmbed(interaction.user,newtype)]})

var newHiddendata = hiddendata.data
newHiddendata.find((value,index) => {
if (value.key == "type"){
newHiddendata[index] = {key:"type",value:newtype}
}
})

const prevDescription = bot.hiddenData.removeHiddenData(firstmsg.embeds[0].description).description
const newData = bot.hiddenData.writeHiddenData("ticketdata",newHiddendata)
const newDescription = prevDescription+newData
const newEmbed = new discord.EmbedBuilder(firstmsg.embeds[0].data)
.setDescription(newDescription)

firstmsg.edit({embeds:[newEmbed]})

interaction.editReply({embeds:[bot.embeds.commands.changeEmbed(interaction.user,newtype)]})

log("command","someone used the 'change' command",[{key:"user",value:interaction.user.tag}])
log("system","ticket type changed",[{key:"user",value:interaction.user.tag},{key:"ticket",value:name},{key:"newtype",value:newtype}])
Expand Down
67 changes: 47 additions & 20 deletions commands/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const config = bot.config
const log = bot.errorLog.log
const l = bot.language
const permsChecker = require("../core/utils/permisssionChecker")
const embed = discord.EmbedBuilder
const storage = bot.storage

const APIEvents = require("../core/api/modules/events")
const DISABLE = require("../core/api/api.json").disable
Expand All @@ -25,27 +27,39 @@ module.exports = () => {
}

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 hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
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)

//msg.channel.send({embeds:[bot.embeds.commands.claimEmbed(claimingUser,msg.author)]})
msg.channel.send({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]})
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].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowNormalNoClaim],embeds:[newEmbed]})

}else if (firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowDisabledNoClaim],embeds:[newEmbed]})
}

msg.channel.send({embeds:[bot.embeds.commands.claimEmbed(claimingUser,msg.author)]})

var loguser = claimingUser
log("command","someone used the 'claim' command",[{key:"user",value:msg.author.tag}])
log("system","user claimed to ticket",[{key:"user",value:msg.author.tag},{key:"ticket",value:msg.channel.name},{key:"claimed_user",value:claimingUser.tag}])

const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true)
//APIEvents.onTicketAdd(msg.author,loguser,msg.channel,msg.guild,new Date(),{status:"open",name:msg.channel.name,ticketOptions:ticketData})
//APIEvents.onCommand("add",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date())
})

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",(interaction) => {
if (!DISABLE.commands.slash.claim) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "claim") return
const user = interaction.options.getUser("user",false) ? interaction.options.getUser("user",true) : interaction.user
Expand All @@ -56,25 +70,38 @@ module.exports = () => {
return
}

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.reply({embeds:[bot.errorLog.notInATicket]})
const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description)
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

//interaction.reply({embeds:[bot.embeds.commands.claimEmbed(user,interaction.user)]})
interaction.reply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]})
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: "+user.tag,iconURL:user.displayAvatarURL()})
.setDescription(hdraw.description+bot.hiddenData.writeHiddenData(hiddendata.type,hiddendata.data))

if (!firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowNormalNoClaim],embeds:[newEmbed]})

}else if (firstmsg.components[0].components[1].disabled){
firstmsg.edit({components:[bot.buttons.firstmsg.firstmsgRowDisabledNoClaim],embeds:[newEmbed]})
}

interaction.editReply({embeds:[bot.embeds.commands.claimEmbed(user,interaction.user)]})

var loguser = user
log("command","someone used the 'claim' command",[{key:"user",value:interaction.user.tag}])
log("system","user claimed to ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"claimed_user",value:loguser.tag}])
log("system","user claimed to ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"claimed_user",value:user.tag}])

const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true)
//APIEvents.onTicketAdd(interaction.user,loguser,interaction.channel,interaction.guild,new Date(),{status:"open",name:interaction.channel.name,ticketOptions:ticketData})
//APIEvents.onCommand("add",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date())

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())
})


})
}
14 changes: 8 additions & 6 deletions commands/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = () => {
}
})

require("../core/ticketActions/ticketCloser").NEWcloseTicket(msg.member,msg.channel,prefix,"close",reason,true)
require("../core/ticketActions/ticketCloser").closeManager(msg.member,msg.channel,prefix,"close",reason,true)

log("command","someone used the 'close' command",[{key:"user",value:msg.author.tag}])
APIEvents.onCommand("close",true,msg.author,msg.channel,msg.guild,new Date())
Expand All @@ -54,24 +54,26 @@ module.exports = () => {

})

if (!DISABLE.commands.slash.close) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.close) client.on("interactionCreate",async(interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "close") return

//interaction.deferReply()

const reason = interaction.options.getString("reason") ? interaction.options.getString("reason") : false

await interaction.deferReply()

interaction.channel.messages.fetchPinned().then(msglist => {
var firstmsg = msglist.last()
if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]})
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

if (hiddendata.data.find(h => h.key == "pendingdelete")) return interaction.reply({embeds:[bot.errorLog.warning("Warning!","You can't close a ticket while it's being deleted!")]})
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!")]})

const descriptionReason = reason ? "**"+l.messages.reason+":** "+reason : false
interaction.reply({embeds:[bot.embeds.commands.closeEmbed(interaction.user,descriptionReason)],components:[bot.buttons.close.closeCommandRow]})
interaction.editReply({embeds:[bot.embeds.commands.closeEmbed(interaction.user,descriptionReason)],components:[bot.buttons.close.closeCommandRow]})

var name = interaction.channel.name
var prefix = ""
Expand All @@ -82,7 +84,7 @@ module.exports = () => {
}
})

require("../core/ticketActions/ticketCloser").NEWcloseTicket(interaction.member,interaction.channel,prefix,"close",false,true)
require("../core/ticketActions/ticketCloser").closeManager(interaction.member,interaction.channel,prefix,"close",false,true)

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())
Expand Down
Loading

0 comments on commit 94ee890

Please sign in to comment.