Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

chpsterz
chpsterz2/19/2023
How to edit an Embed(Documentation isn't working)

Hi.

Trying to make a discord bot that will send a message to a specific channel on startup. I have the message sent to the specific channel on startup, however, when I try to edit it a error is thrown saying message.edit is not a function. I am following the direct steps from the documentation and it is not working. Why and how do I fix this issue?

         let message: any;

    if(channel?.isTextBased() ) {
            message = channel.send({ embeds: [ playerCountEmbedLoading() ] });
    }

    setInterval(() => {
             if(channel?.isTextBased() ) {
            return message.edit({ embeds: [ playerCountEmbed() ] })
          }
    }, 3000)
chpsterz
chpsterz2/19/2023
Yes I am aware that my code doesn't follow the structure mentioned here https://discord.com/channels/737141877803057244/1076513439524077598/1076552454147145879, I have not bothered to change that yet and I believe that is not related to the bug at hand as far as I know?
Favna
Favna2/19/2023
is is related
Favna
Favna2/19/2023
also this isn't sapphire related, #1047162744710889504 next time please.
chpsterz
chpsterz2/19/2023
now I have the same error as before
chpsterz
chpsterz2/19/2023
chpsterz
chpsterz2/19/2023
Favna
Favna2/19/2023
cant see your code
Favna
Favna2/19/2023
should be isTextChannel(channel) && !isStageChannel(channel)
chpsterz
chpsterz2/19/2023
k that fixes the sending issue
chpsterz
chpsterz2/19/2023
this isn't flagged in the code but during run time
chpsterz
chpsterz2/19/2023
C:\Users\paaxy\Documents\sploop-bot-entry-detection'\sploop-bot-entry-detection\dist\index.js:79
                return message.edit({ embeds: [playerCountEmbed()] });
                               ^

TypeError: message.edit is not a function
    at Timeout._onTimeout (C:\Users\paaxy\Documents\sploop-bot-entry-detection'\sploop-bot-entry-detection\dist\index.js:79:32)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Node.js v18.14.0
Favna
Favna2/19/2023
Idk then
Favna
Favna2/19/2023
Check whether it exists I guess
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy