Why is my bot not editing its own message

Hey, I have coded my bot to have a "Refresh" button on one of its messages which allows members to get the latest information (fetched from my local sequelize db). This is working great in 90% of the guilds and channels, however I had a report of it not working in this particular guild and channel and I can confirm that to be the case. I looked through some previous messages in this discord and they suggested logging out isEditable and having a look at the permissions against the bot user. So I coded this into the command.
const isEditable = interaction.message.editable
console.log({ isEditable, bot: interaction.guild?.members.me?.permissionsIn(interaction.message.channelId) })
const isEditable = interaction.message.editable
console.log({ isEditable, bot: interaction.guild?.members.me?.permissionsIn(interaction.message.channelId) })
and I get.
{
isEditable: true,
bot: PermissionsBitField { bitfield: 533235326373441n }
}
{
isEditable: true,
bot: PermissionsBitField { bitfield: 533235326373441n }
}
I also check to see if the bot is in the channels member list like so
!!channel.members.find((member) => member.id === client.user?.id)
!!channel.members.find((member) => member.id === client.user?.id)
and it is. I edit the message like so
try {
await interaction.message.edit({
embeds: embeds as APIEmbed[],
content: eventSession.closed ? i18next.t('message.events.sessionIsClosed') : undefined,
components,
})
const secs = 3
replyEphemeral(interaction, `${getAutoDismissMessage(secs)}\n\n${i18next.t('sessionTimesHaveBeenUpdated')}`, secs * 1000)
} catch (error) {
logger.error('[buttonRefreshGetSignupsInteraction]', { error })
replyEphemeral(interaction, i18next.t('message.error.unexpected'))
}
}
try {
await interaction.message.edit({
embeds: embeds as APIEmbed[],
content: eventSession.closed ? i18next.t('message.events.sessionIsClosed') : undefined,
components,
})
const secs = 3
replyEphemeral(interaction, `${getAutoDismissMessage(secs)}\n\n${i18next.t('sessionTimesHaveBeenUpdated')}`, secs * 1000)
} catch (error) {
logger.error('[buttonRefreshGetSignupsInteraction]', { error })
replyEphemeral(interaction, i18next.t('message.error.unexpected'))
}
}
and no error is thrown. I know the edit isn't working because I stuck a UUID into the message that changes on each edit and that has not changed. Can I have some guidance on what could be causing the bot to successfully edit the message (as in doesn't throw an error), however not actually edit the message?
No description
4 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
BeardedGaming
BeardedGamingOP13mo ago
[email protected] node v18.17.0 I can also confirm that time between the command being executed and the refresh button being clicked is not an issue because this situation happens as soon as the user creates the message and clicks refresh.
BeardedGaming
BeardedGamingOP13mo ago
This is visually what it looks like. The UUID normally sits beneath the Updated at in the first embed, but on this screenshot I haven't added it in yet
No description
BeardedGaming
BeardedGamingOP13mo ago
You think that'll work? The update worked a treat. Thank you! Still interested to know why no error was thrown with the edit() function.
Want results from more Discord servers?
Add your server