Reputation:
I cant really figure out how to do this without iterating through all voicechannels and compare the user ids, but this is veeeery slow. Is there a better way? I want to know this, because my Music Bot should add a song to the queue if the User who wrote the command is in the same voice channel as the Bot
Upvotes: 0
Views: 409
Reputation: 11
if (ctx.guild.voice_client.channel == ctx.message.author.voice.channel):
Upvotes: 1
Reputation: 5650
You can use Member.voice
and VoiceState.channel
to get the current voice state of both the bot & the person that wrote it (ctx.author
) to get the channels immediately without having to loop through anything. Voice
returns None
if they aren't currently in a VoiceChannel
.
Upvotes: 0