v3.3 push 6 (added ticket claiming)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
const discord = require('discord.js')
|
||||
const bot = require('../../../../index')
|
||||
const client = bot.client
|
||||
const config = bot.config
|
||||
const l = bot.language
|
||||
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 button = discord.ButtonBuilder
|
||||
const arb = discord.ActionRowBuilder
|
||||
const bs = discord.ButtonStyle
|
||||
|
||||
module.exports = () => {
|
||||
//CLAIM
|
||||
client.on("interactionCreate",async interaction => {
|
||||
if (!interaction.isButton()) return
|
||||
if (interaction.customId != "OTclaimTicket") return
|
||||
|
||||
try {
|
||||
interaction.deferUpdate()
|
||||
}catch{}
|
||||
|
||||
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].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]})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user