VoiceState always returning None as 'channel' value

Question:

I’m messing around creating a discord bot, but the VoiceState objetcs that I get always have the channel value to None.

intents = discord.Intents(messages=True, voice_states=True)
client = discord.Client(intents=intents)

@client.event
async def on_voice_state_update(member, before, after):
  print("Channel event", member, before.channel, after.channel)
  print(member.voice)

I’m not able to get the event channel values from after, before nor Member.voice.

Any suggetions? Is it bugged?

Thank you all!

Trying to get the channel from on_voice_state_update always returns None

Asked By: Kuerdix

||

Answers:

To see the channels of a guild, you also need to enable the guilds intent, like this:

intents = discord.Intents(messages=True, voice_states=True, guilds=True)

Here is a list of all intents: https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents

Hope this helps.

Answered By: moinierer3000
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.