Skip to content

Insufficient error message for member.displayHexColor when GUILDS intent is missing #8301

Open
@MaksiRose

Description

@MaksiRose

Which package is this bug report for?

discord.js

Issue description

  1. Create a bot without GUILDS intent.
  2. Get a guild member
  3. call member.displayHexColor
  4. Get an error

The problem here is not inherently with getting an error, but rather with the fact that the error is hard to understand for someone who has no idea that they are missing the GUILDS intent. They might try to console log, but will only get this error again, not undefined or anything. I fully believe this is very confusing and there should be a check for the guilds intent (or if the roles cache is empty) that throws with the message that the GUILDS intent is missing.
Screenshot from 2022-07-17 17-23-35

Code sample

const client = new Client({
  intents: [],
})

client.on('interactionCreate, async (interaction) => {
  if (!interaction.member || interaction.member === undefined) { return; }
  console.log(interaction?.member?.displayHexColor) // This will error
})

Package version

13.8.1

Node.js version

17.5.0

Operating system

Linux Manjaro

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

Not applicable (subpackage bug)

Which gateway intents are you subscribing to?

No Intents

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions