How to mention users when they connect to a specific voice channel

Viewed 88

My discord bot is supposed to create voice channels and get information about users (in order to mention them later) in these channels. The order of actions is that the user connects to specific channel, and then bot creates a new channel and moves user to it. After that, the user uses !invite, then the bot sends message with mention of user who created this channel. Also bot edits it with mention of just connected user.

The problem is that I need to get another user id immediately when he connected to created_channel.

client = commands.Bot(command_prefix='!', intents = discord.Intents.all())

@client.command(name='invite')
async def invite(ctx: commands.context):
    poster = discord.Embed(colour = 0xFF5500)
    poster.add_field(name = ctx.message.content[7:],
    value = f'''{new_connected1.mention}
    {new_connected2.mention}
    {new_connected3.mention}
    {new_connected4.mention}
    {new_connected5.mention}'''
    )
    await ctx.send(embed = poster)

@client.event
async def on_voice_state_update( member, before, after ):
    if after.channel.id == 1019214989829079060: #channel where I connect to create another channel
        for guild in client.guilds:
            category_contains_created_channel = discord.utils.get( guild.categories, id = 1019215017150787604) #category where I want to place new channel
            created_channel = await guild.create_voice_channel(name = f"{member.display_name}'s", category = category_contains_created_channel, user_limit = 5) #creating channel
            await created_channel.set_permissions(member, connect = True, mute_members = True, move_members = True) #setting perimissions
            await member.move_to(created_channel) #moving member to new channel

            def check(x, y, z):
                return len(created_channel.members) == 0 #checking members in the channel
            await client.wait_for('voice_state_update', check = check)
            await created_channel.delete() #deleting channel if none is in the channel
0 Answers
Related