How to get Discord member username from user id in python and move to another channel?

Professional JK

I have got the list of user ids of all member from a voice channel

client = commands.Bot(command_prefix = '+'
@client.command()
async def move(ctx):
  voice_channel = discord.utils.get(ctx.guild.channels, name="Meeting")
  memid= voice_channel.voice_states.keys()
  memlist=list(memid)
  for i in range(0, len(memlist))
    user = memlist[i]
    await user.move_to('Meeting-2')

I want to move all the users from one channel to another channel

Domi

You need to use user = await client.fetch_user(userid) to get a user object from an id, however to move a user from one vc to another you need a member object. This can be done with member = await ctx.guild.fetch_member(userid) with guild being guild = client.get_guild(server_id) if you don't have ctx.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related