This commit is contained in:
DJj123dj
2023-08-30 17:22:26 +02:00
parent 589bbe5cd5
commit 5f19adf561
32 changed files with 91 additions and 60 deletions
+32 -19
View File
@@ -14,6 +14,7 @@ module.exports = () => {
if (!DISABLE.commands.text.change) client.on("messageCreate", async msg => {
if (!msg.content.startsWith(config.prefix+"change")) return
if (!msg.channel.isTextBased()) return
if (!msg.guild) return
if (!permsChecker.command(msg.author.id,msg.guild.id)){
@@ -26,26 +27,42 @@ module.exports = () => {
const ticketId = hiddendata.find(d => d.key == "type").value
const list = []
config.options.forEach((o) => list.push(o.id))
config.options.forEach((o) => {
if (o.type == "ticket") list.push(o.id)
})
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)
const newTicket = require("../core/utils/configParser").getTicketById(newtype,true)
if (!newTicket) return msg.channel.send({embeds:[bot.errorLog.invalidIdChooseFromList(list,l.errors.missingArgsDescription+" `<type>`:\n`"+config.prefix+"change <type>`")]})
/**@type {discord.PermissionOverwriteManager} */
const prePermsManager = msg.channel.permissionOverwrites
const prePerms = prePermsManager.cache
/**@type {String} */
var chName = msg.channel.name
const splitted = chName.split("-")
const prefix = splitted.shift()
const name = (splitted.length > 0) ? splitted.join("-") : prefix
if (newTicket.category){
const parent = await msg.guild.channels.fetch(newTicket.category,{cache:true})
if (parent && parent.type == discord.ChannelType.GuildCategory) msg.channel.setParent(parent)
}
msg.channel.setName(newTicket.channelprefix+name)
prePermsManager.set(prePerms)
msg.channel.setName(newTicket.channelprefix+name).catch(() => {
msg.channel.send({embeds:[bot.errorLog.failedRenameChannel]})
})
hiddendata.find((value,index) => {
if (value.key == "type"){
hiddendata[index] = {key:"type",value:newtype}
}
})
msg.channel.send({embeds:[bot.embeds.commands.changeEmbed(msg.author,newtype)]})
log("command","someone used the 'change' command",[{key:"user",value:msg.author.username}])
@@ -56,6 +73,7 @@ module.exports = () => {
if (!DISABLE.commands.slash.change) client.on("interactionCreate",async (interaction) => {
if (!interaction.isChatInputCommand()) return
if (interaction.commandName != "change") return
if (!interaction.channel.isTextBased()) return
if (!interaction.guild) return
if (!permsChecker.command(interaction.user.id,interaction.guild.id)){
@@ -69,7 +87,9 @@ module.exports = () => {
const ticketId = hiddendata.find(d => d.key == "type").value
const list = []
config.options.forEach((o) => list.push(o.id))
config.options.forEach((o) => {
if (o.type == "ticket") list.push(o.id)
})
var newtype = interaction.options.getString("type",true)
const newTicket = require("../core/utils/configParser").getTicketById(newtype,true)
@@ -91,24 +111,17 @@ module.exports = () => {
if (parent && parent.type == discord.ChannelType.GuildCategory) interaction.channel.setParent(parent)
}
await prePermsManager.set(prePerms)
interaction.channel.setName(newTicket.channelprefix+name)
prePermsManager.set(prePerms)
interaction.channel.setName(newTicket.channelprefix+name).catch(() => {
interaction.channel.send({embeds:[bot.errorLog.failedRenameChannel]})
})
var newHiddendata = hiddendata.data
newHiddendata.find((value,index) => {
hiddendata.find((value,index) => {
if (value.key == "type"){
newHiddendata[index] = {key:"type",value:newtype}
hiddendata[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.username}])
+14 -9
View File
@@ -14,7 +14,7 @@ const DISABLE = require("../core/api/api.json").disable
module.exports = () => {
bot.errorLog.log("debug","COMMANDS: loaded claim.js")
if (!DISABLE.commands.text.claim) client.on("messageCreate",msg => {
if (!DISABLE.commands.text.claim) client.on("messageCreate", async msg => {
if (!msg.content.startsWith(config.prefix+"claim")) return
var user = msg.mentions.users.first()
@@ -34,14 +34,19 @@ module.exports = () => {
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.username,iconURL:msg.author.displayAvatarURL()})
await 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 newEmbed = new embed(firstmsg.embeds[0].data)
.setFooter({text:"claimed by: "+msg.author.username,iconURL:msg.author.displayAvatarURL()})
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]})
}
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]})
}
})
msg.channel.send({embeds:[bot.embeds.commands.claimEmbed(claimingUser,msg.author)]})
@@ -74,7 +79,7 @@ module.exports = () => {
bot.hiddenData.writeHiddenData(interaction.channel.id,hiddendata)
storage.set("claimData",interaction.channel.id,user.id)
interaction.channel.messages.fetchPinned().then(msglist => {
await 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]})
+1 -1
View File
@@ -38,7 +38,7 @@ module.exports = () => {
}
if (args[1]){
if (!args[1].startsWith("close") && !args[1].startsWith("delete") && !args[1].startsWith("remove") && !args[1].startsWith("add") && !args[1].startsWith("msg") && !args[1].startsWith("remove") && !args[1].startsWith("rename") && !args[1].startsWith("reopen")){
if (!args[1].startsWith("close") && !args[1].startsWith("delete") && !args[1].startsWith("remove") && !args[1].startsWith("add") && !args[1].startsWith("msg") && !args[1].startsWith("remove") && !args[1].startsWith("rename") && !args[1].startsWith("reopen") && !args[1].startsWith("change") && !args[1].startsWith("claim") && !args[1].startsWith("unclaim")){
msg.channel.send({embeds:[helpEmbed]})
log("command","someone used the 'help' command",[{key:"user",value:msg.author.username}])
APIEvents.onCommand("help",true,msg.author,msg.channel,msg.guild,new Date())