Problem with onMessageDelete
Hello Guys,
Im facing a really weird problem.
I have this 1. code where i have a normal message loggin what is working:
82 Replies
- 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!Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
discord.js@14.19.3
v20.14.0
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
Yea i dont have nitro, i need to split the msgs cuz of the length
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
Writing it right now
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
I have a ticket panel creation command that creates a ticket panel and saves the channel ID, message ID, and other related data to the database.
Additionally, I have a second event handler that listens for deleted messages: if the message ID of a ticket panel is deleted, it removes the corresponding entry from the database.
However, if I create a panel, then restart the Discord bot, and afterwards delete the panel's message ID, the entry is not removed from the database.
Code:
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
No?
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
Also
Look:
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
its a discordjs issue afaik
cuz that makes no sense its on my db
cuz:
if i create a ticket panel, -> data will be saved to the db, then delete the messageId of the panel -> the panel gets deleted out of the db
but when i restart the bot after i created the panel and want to delete the message with the same messageId of a panel, nothing happens
I cant understand why
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
Lemme show you everything
This embed is my "panel"

and after creating the embed aka panel for my ticket system
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View

look it will be save everything good until
and when the bot runtime is still the same like if i did not restart the bot
when i delete now the panel aka the panelMessageId -> the entry from the array will be deleted
but when i create a panel, stop the bot, start the bot and delete a panel, the panel entry in the db is not deleted
thats my issue
and i dont save anything in the memory
cuz its all in the db
and i even asked a other dev friend who dont even know it either
(bot still on) -> success

Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
it is
its only working
when the bot is still on
thats my issue
but if i restart it
and delete a msg
its not triggered
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
example if the bot crashed
that will be a public bot
example
one day
but i still wanna know why that thing is not working with the event also messageDelete
when the bot restarts
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
no im waiting
i got logs when the bot is ready etc
and im waiting enough
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
enough that in this time other cmds are working
you know
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
i even waited minutes
and if other cmds are working etc why should not work the event handler
β Lizard: Database initialized & synchronized. π¦ Lizard: Modules imported successfully. π¦ Lizard: Bot Ready: (π Single/Unsharded)
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
also
How does the Event handle the messages?
Cuz if i write messages, and restart the bot after -> the messages are not getting deleted aka logged with my other event handler
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
only the messages getting logged when the bot is started and all after

Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildModeration,
IntentsBitField.Flags.GuildPresences,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.AutoModerationExecution,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.GuildVoiceStates,
IntentsBitField.Flags.MessageContent,
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
dont think so
im not the best exp developer, what are partials exactly?
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
yea
the event handler are working
but only for new messages after the login of the bot
and thats why i cant delete the panel message id aka the code execution for the entry remove on the d
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
u see

bot on
i write message
delete it
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
mb xd
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
okay so is it from my site a issue? i dont think so
im using everything normal.
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
its the same
yea im doing that no?
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
if the delete message is a panelMessageId
remove the entry
from db
and its only works when the panel is created when bot is on or is still on you know
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
config.pluginConfigs?.ticketPlugin?.panels is this
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
"pluginConfigs": {
"ticketPlugin": {
"enabled": true,
"panels": [
{
"ticketCounter": "0",
"categoryId": "1371240562677780612",
"ticketRoleId": [
"1355351245006704952"
],
"panelMessageId": "1379938637340348598"
}
]
}
},
an array of this entity for the plugin:
:mdn: Array.prototype.filter()
The filter() method of Array instances creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.
panels returns an array of panel objects or undefined if none exist
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
i mean thats the bot for testing
nothing is live
but the issue is, that the event is not triggering
and the code works when the runtime is same
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
and how can i cache it
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
hm
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
oh man
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
hm
so whats the best use case for this scenario
i dont want to have then soon when the bot is live for everyone free to use that someone have like 500000 data of created ticket panels
want to have it clear you know
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
hmmm
how other bots handles that
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
Hm
Yea idk man im struggling with this shit for some hrs
gettin crashout soon
Unknown Userβ’6mo ago
Message Not Public
Sign In & Join Server To View
okay i will see thank you very much
@jΓΆ π Omg i got it working.
& using:
& then i fetch the deleted msg -> Deleted panel with messageId 1379984623441809449 from guild 1355346662440173789.
nice finally.
You can't fetch a deleted structure, there's nothing to retrieve from the API :Thonk: