Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: message#channel still returns old TextChannel instance after change to news type channel #6168

Closed
almostSouji opened this issue Jul 22, 2021 · 1 comment · Fixed by #6263

Comments

@almostSouji
Copy link
Member

Please describe the problem you are having in as much detail as possible:

message#channel still returns old TextChannel instance after change to news type channel

Include a reproducible code sample here, if possible:

  1. create a text channel
  2. make it a news channel (can be manual through GUI)
  3. get <Message>.channel inside this (now news) channel

observe: you get a TextChannel of type GUILD_TEXT
reason:

if (ChannelTypes[channel.type] !== data.type) {
const newChannel = Channel.create(this.client, data, channel.guild);
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
this.client.channels.cache.set(channel.id, channel);
}

we do transfer the messages to the new channel, however, each message still has the old channel (due to Message#channel not being a getter but a value)

Further details:

  • discord.js version: 328501b
  • Node.js version: 16.5
  • Operating system: n/a
  • Priority this issue should have – please be realistic and elaborate if possible: medium

Relevant client options:

  • partials: n/a
  • gateway intents: GUILDS, GUILD_MESSAGES
  • other: n/a
@almostSouji
Copy link
Member Author

The most straight-forward and least hacky solution I can think of would be to make Message#channel a getter which retrieves this from cache instead. I can't find any reason so far why this would benefit from being a fix value vs. a getter

Alternatively this could be addressed by iterating over the message cache and setting the new channel to each message (though that seems to be quite the elaborate and hacky work-around)

@iCrawl iCrawl linked a pull request Aug 1, 2021 that will close this issue
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant