v3.3 push 3 (lots of small changes 😄)

This commit is contained in:
DJj123dj
2023-03-13 20:22:23 +01:00
parent ee248e86bc
commit 944032f690
34 changed files with 136 additions and 188 deletions
+5 -3
View File
@@ -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")
@@ -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}])
+38 -15
View File
@@ -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
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>`")]})
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)
var newtype = msg.content.split(config.prefix+"change")[1].substring(1)
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)
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
@@ -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
@@ -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("-")
@@ -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}])
+6 -4
View File
@@ -45,7 +45,7 @@ module.exports = () => {
})
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
@@ -56,14 +56,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.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!")]})
//interaction.editReply({embeds:[bot.embeds.commands.claimEmbed(user,interaction.user)]})
interaction.editReply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]})
var loguser = user
log("command","someone used the 'claim' command",[{key:"user",value:interaction.user.tag}])
+6 -4
View File
@@ -54,7 +54,7 @@ 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
@@ -62,16 +62,18 @@ module.exports = () => {
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 = ""
+5 -5
View File
@@ -47,25 +47,25 @@ module.exports = () => {
})
if (!DISABLE.commands.slash.delete) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.delete) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "delete") return
//interaction.deferReply()
if (!interaction.guild) return
if (!permsChecker.command(interaction.user.id,interaction.guild.id)){
permsChecker.sendUserNoPerms(interaction.user)
return interaction.reply({embeds:[bot.errorLog.noPermsDelete(interaction.user)]})
}
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.reply({embeds:[bot.embeds.commands.deleteEmbed(interaction.user)]})
interaction.editReply({embeds:[bot.embeds.commands.deleteEmbed(interaction.user)]})
var name = interaction.channel.name
var prefix = ""
+4 -2
View File
@@ -55,14 +55,16 @@ module.exports = () => {
return
}
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.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.delete(user.id)
interaction.reply({embeds:[bot.embeds.commands.removeEmbed(user,interaction.user)]})
interaction.editReply({embeds:[bot.embeds.commands.removeEmbed(user,interaction.user)]})
var loguser = user
+4 -4
View File
@@ -53,7 +53,7 @@ module.exports = () => {
})
if (!DISABLE.commands.slash.rename) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.rename) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "rename") return
@@ -63,11 +63,11 @@ module.exports = () => {
return
}
//interaction.deferReply()
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
@@ -84,7 +84,7 @@ module.exports = () => {
if (!prefix) prefix = "noprefix-"
interaction.channel.setName(prefix+newname)
interaction.reply({embeds:[bot.embeds.commands.renameEmbed(interaction.user,prefix+newname)]})
interaction.editReply({embeds:[bot.embeds.commands.renameEmbed(interaction.user,prefix+newname)]})
log("command","someone used the 'rename' command",[{key:"user",value:interaction.user.tag}])
log("system","ticket renamed",[{key:"user",value:interaction.user.tag},{key:"ticket",value:name},{key:"newname",value:newname}])
+4 -4
View File
@@ -37,17 +37,17 @@ module.exports = () => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "reopen") return
//interaction.deferReply()
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.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 re-open 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 re-open a ticket while it's being deleted!")]})
await interaction.reply({embeds:[bot.embeds.commands.reopenEmbed(interaction.user)],components:[bot.buttons.close.openRowNormal]})
await interaction.editReply({embeds:[bot.embeds.commands.reopenEmbed(interaction.user)],components:[bot.buttons.close.openRowNormal]})
require("../core/ticketActions/ticketReopener").reopenTicket(interaction.guild,interaction.channel,interaction.user)
+2 -2
View File
@@ -30,8 +30,8 @@ module.exports = () => {
const id = msg.content.split(config.prefix+"msg")[1].substring(1) ? msg.content.split(config.prefix+"msg")[1].substring(1) : false
if (!id) return msg.channel.send({embeds:[bot.errorLog.invalidArgsMessage(l.errors.missingArgsDescription+" `<id>`:\n`"+config.prefix+"msg <id>`")]})
if (!msgIds.includes(id)) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(msgIds)]})
if (!id) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(msgIds,l.errors.missingArgsDescription+" `<id>`:\n`"+config.prefix+"msg <id>`")]})
if (!msgIds.includes(id)) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(msgIds,l.errors.missingArgsDescription+" `<id>`:\n`"+config.prefix+"msg <id>`")]})
const {embed,componentRows} = require("../core/utils/getEmbed").createEmbed(id)
+6 -4
View File
@@ -42,7 +42,7 @@ module.exports = () => {
})
if (!DISABLE.commands.slash.unclaim) client.on("interactionCreate",(interaction) => {
if (!DISABLE.commands.slash.unclaim) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "unclaim") return
const user = interaction.user
@@ -53,14 +53,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.reply({embeds:[bot.embeds.commands.unclaimEmbed(interaction.user)]})
interaction.reply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]})
//interaction.editReply({embeds:[bot.embeds.commands.unclaimEmbed(interaction.user)]})
interaction.editReply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]})
var loguser = user
log("command","someone used the 'unclaim' command",[{key:"user",value:interaction.user.tag}])