Paul
Paul
DIAdiscord.js - Imagine an app
Created by Paul on 6/26/2024 in #djs-questions
How to approach "replacing" (finding/deleting/reposting) a message in a designated channel?
Ok, thanks. This confirms for me that there isn't an obvious Discord API trick I'm missing, then. I'll consider keeping local data, definitely a toss-up between whether a stateless bot reacting to events without file support is simpler or whether recordkeeping code is simpler. Just need to ponder my philosophy I guess. Recordkeeping would definitely minimize per-hit computation requirements at least. Thanks for thinking about it and responding!
9 replies
DIAdiscord.js - Imagine an app
Created by Paul on 6/26/2024 in #djs-questions
How to approach "replacing" (finding/deleting/reposting) a message in a designated channel?
Update: I just found
channel.messages.fetch().then(messages => ... messages.filter(message => ...))
channel.messages.fetch().then(messages => ... messages.filter(message => ...))
here: https://discord.js.org/docs/packages/discord.js/14.15.3/GuildMessageManager:Class#fetch That seems promising for what I want to do. (In my case filtering on author id is not useful because the bot posts everything, but maybe I can use this to construct a more appropriate filtering function.) I will try this. Though it's really just mostly compacting the code footprint from what I had before, while still implementing the same approach. It's still ultimately retrieving all the messages from Discord and then parsing through them locally. If I could retrieve just the message I want rather than 100 of them from the API, that is the dream.
9 replies