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

Message.editable doesn't work in threads #6969

Closed
Pjiesco opened this issue Nov 11, 2021 · 1 comment · Fixed by #6975
Closed

Message.editable doesn't work in threads #6969

Pjiesco opened this issue Nov 11, 2021 · 1 comment · Fixed by #6975

Comments

@Pjiesco
Copy link

Pjiesco commented Nov 11, 2021

Issue description

Steps to reproduce:

  1. register event for the messageCreate event.
  2. Send a message in a thread
  3. See how it fails.

Possible cause (I'm almost certain that this is the cause):
It tries to run this.channel?.viewable on the thread channel but thread channels do not have a viewable property resulting in null/false

  get editable() {
    return Boolean(this.author.id === this.client.user.id && !this.deleted && (!this.guild || this.channel?.viewable));
  }

Source

Code sample

client.on('messageCreate', (message) => {
    if (message.channel.type == ChannelType.GuildPublicThread) {
        if (message.editable) {
            message.edit("Edited message");
        }
    }
})

discord.js version

13.3.1

Node.js version

16.6.1

Operating system

Windows

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

GUILDS, GUILD_MEMBERS, GUILD_BANS, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING

I have tested this issue on a development release

No response

@Jiralite
Copy link
Member

Possible cause (I'm almost certain that this is the cause):
It tries to run this.channel?.viewable on the thread channel but thread channels do not have a viewable property resulting in null/false

Yep, that'll be the cause. Thread channels don't have this property, so this becomes undefined, so the expression becomes true && true && (false || undefined) which gets converted to false.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants