'DiscordJS MessageManager is a circular dependency
I try to get a message by id in discord.js, but returned MessageManager is a circular dependency and I cannot access any of it's properties.
console.log(channel.messages)
Shows:
<ref *2> MessageManager {
channel: <ref *1> TextChannel {
type: 'GUILD_TEXT',
guild: Guild { ... }
And
channel.messages.fetch(msg_ID)
.then(msg => {
console.log(msg)
})
Shows this, but repeated 50 times:
'msg_ID' => <ref *50> Message {
channelId: 'channel_ID',
guildId: 'guild_ID',
id: 'msg_ID',
createdTimestamp: 1652473636758,
type: 'DEFAULT',
and a bunch of other fields (obviously I changed IDs to 'msg_ID', 'channel_ID' and 'guild_ID', normally it returns proper numbers)
Solution 1:[1]
Apparently this is caused by passing msg_ID as a Number. Most discord.js methods require their input being casted to String as specified here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
