'TypeError this.options.components?.map is not a function' when using spliceComponents() function

Hello there. I am fairly certain this is a bug rather than a question. I tried using the spliceComponents() function and got this error in return:
TypeError: this.options.components?.map is not a function
at MessagePayload.resolveData (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\structures\MessagePayload.js:141:49)
at MessageManager.edit (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\managers\MessageManager.js:130:8)
at Message.edit (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\structures\Message.js:702:34)
at Interaction.callback (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\Cogs\ticket.js:240:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
TypeError: this.options.components?.map is not a function
at MessagePayload.resolveData (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\structures\MessagePayload.js:141:49)
at MessageManager.edit (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\managers\MessageManager.js:130:8)
at Message.edit (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\node_modules\discord.js\src\structures\Message.js:702:34)
at Interaction.callback (C:\Users\Batman212369\Desktop\Discord Bots\MyBot\Cogs\ticket.js:240:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Here is the code that generated this error:
Cog.add = new Interaction("claimTicket", async (interaction) => {
let ticket = await fetchTicketInfo({channelId: interaction.channelId})
if (ticket.claimantId) {
await interaction.reply({content: `This channel has already been claimed by <@${ticket.claimantId}>.`, ephemeral: true})
return
}

ticket.claimantId = interaction.user.id
await updateTicketInfo(ticket)

const unclaimButton = new MessageButton()
.setCustomId('unclaimTicket')
.setLabel('📝 Unclaim')
.setStyle('PRIMARY')

const message = interaction.message
const messageComponents = await message.components[0].spliceComponents(0, 1, [unclaimButton])
await interaction.reply({content: "Successfully claimed channel!", ephemeral: true})
await message.edit({content: message.content, embeds: message.embeds, components: messageComponents})
})
Cog.add = new Interaction("claimTicket", async (interaction) => {
let ticket = await fetchTicketInfo({channelId: interaction.channelId})
if (ticket.claimantId) {
await interaction.reply({content: `This channel has already been claimed by <@${ticket.claimantId}>.`, ephemeral: true})
return
}

ticket.claimantId = interaction.user.id
await updateTicketInfo(ticket)

const unclaimButton = new MessageButton()
.setCustomId('unclaimTicket')
.setLabel('📝 Unclaim')
.setStyle('PRIMARY')

const message = interaction.message
const messageComponents = await message.components[0].spliceComponents(0, 1, [unclaimButton])
await interaction.reply({content: "Successfully claimed channel!", ephemeral: true})
await message.edit({content: message.content, embeds: message.embeds, components: messageComponents})
})
Not really sure if there's a solution except from waiting for a bug fix. If there is, please let me know. Thank you.
14 Replies
mooz.tsx
mooz.tsx2y ago
Log messageComponents
Batimius
Batimius2y ago
Batimius
Batimius2y ago
I assume this is a discord.js error because it originates from the library itself, not my code. This happens with the setComponents() function as well. This is the components in general. One second.
mooz.tsx
mooz.tsx2y ago
you are v13.8 right?
Batimius
Batimius2y ago
Yes.
mooz.tsx
mooz.tsx2y ago
yeah I wanted messageComponents exactly
Batimius
Batimius2y ago
MessageActionRow {
type: 'ACTION_ROW',
components: [
MessageButton {
type: 'BUTTON',
label: '📝 Unclaim',
customId: 'unclaimTicket',
style: 'PRIMARY',
emoji: null,
url: null,
disabled: false
},
MessageButton {
type: 'BUTTON',
label: '🔒 Close',
customId: 'closeTicket',
style: 'DANGER',
emoji: null,
url: null,
disabled: false
}
]
}
MessageActionRow {
type: 'ACTION_ROW',
components: [
MessageButton {
type: 'BUTTON',
label: '📝 Unclaim',
customId: 'unclaimTicket',
style: 'PRIMARY',
emoji: null,
url: null,
disabled: false
},
MessageButton {
type: 'BUTTON',
label: '🔒 Close',
customId: 'closeTicket',
style: 'DANGER',
emoji: null,
url: null,
disabled: false
}
]
}
mooz.tsx
mooz.tsx2y ago
oh just put it in an array
Batimius
Batimius2y ago
🤦 Yep. That was the problem. Thanks, lol.
mooz.tsx
mooz.tsx2y ago
There's no bug lmao
Batimius
Batimius2y ago
I thought the error happened at the sliceComponents() part,
mooz.tsx
mooz.tsx2y ago
Sure, no problem.
Batimius
Batimius2y ago
My bad, lol.
mooz.tsx
mooz.tsx2y ago
no read it Clearly says MessagePayload anyway have a nice day ig