'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.tsx3y ago
Log messageComponents
Batimius
BatimiusOP3y ago
Batimius
BatimiusOP3y 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.tsx3y ago
you are v13.8 right?
Batimius
BatimiusOP3y ago
Yes.
mooz.tsx
mooz.tsx3y ago
yeah I wanted messageComponents exactly
Batimius
BatimiusOP3y 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.tsx3y ago
oh just put it in an array
Batimius
BatimiusOP3y ago
🤦 Yep. That was the problem. Thanks, lol.
mooz.tsx
mooz.tsx3y ago
There's no bug lmao
Batimius
BatimiusOP3y ago
I thought the error happened at the sliceComponents() part,
mooz.tsx
mooz.tsx3y ago
Sure, no problem.
Batimius
BatimiusOP3y ago
My bad, lol.
mooz.tsx
mooz.tsx3y ago
no read it Clearly says MessagePayload anyway have a nice day ig
Want results from more Discord servers?
Add your server