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)
let message: any;

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

setInterval(() => {
if(channel?.isTextBased() ) {
return message.edit({ embeds: [ playerCountEmbed() ] })
}
}, 3000)
8 Replies
chpsterz
chpsterz2y ago
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
Favna2y ago
is is related also this isn't sapphire related, #discordjs-support next time please.
chpsterz
chpsterz2y ago
now I have the same error as before
chpsterz
chpsterz2y ago
chpsterz
chpsterz2y ago
Favna
Favna2y ago
cant see your code should be isTextChannel(channel) && !isStageChannel(channel)
chpsterz
chpsterz2y ago
k that fixes the sending issue this isn't flagged in the code but during run time
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
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
Favna2y ago
Idk then Check whether it exists I guess
Want results from more Discord servers?
Add your server