1
votes

I've searched all over Stack Overflow and found many questions people asked on how to move one member or all members into a voice channel, but the answer didn't fit my needs and when I just tried them to see if maybe I could change them to fit my needs they didn't work.

On my discord server if you join a voice channel called Join to create channel, I want my bot to make a voice channel named like this: f'{member}s channel' and then move the person into that channel automatically. I can get the bot to make the channel by using await clone(name, reason), but for some reason I can't get the bot to move the member into the voice channel.

This is what I have at the moment:

import discord
import datetime


client = discord.Client()


@client.event
async def on_voice_state_update(member, before, after):
    if str(after.channel) == 'Join to create channel':
        if str(after) != str(before):
            await after.channel.clone(name=f'{member}s channel')
            person_to_move = member
            channel_to_move_person_to_move_to = client.get_channel(f'{member}s channel')
            await client.move_member(person_to_move, channel_to_move_person_to_move_to)

Whenever I run this code I get an AttributeError saying that "Client" has no attribute "move_member" move_member is something I saw on Stack Overflow every time I search for an answer. Originally I had:

await move_to(person_to_move, channel_to_move_person_to_move_to)

Which is what I found in discord py API documentation. The error there however is that it gave me a NameError saying "move_to" is not defined.

Any info would be helpful. Am I missing a small thing or am I doing this completely wrong? Thanks.

1
Just tell me If there is anything you don't understand or need clarification for - Remi_Zacharias

1 Answers

1
votes

You can move people using the member object.

channel = discord.utils.get(guild.text_channels, name = f"{member}'s channel")
await member.move_to(channel)