如何在未连接的情况下将用户添加到 VC

问题描述 投票:0回答:1

为了扩展我的问题,我想将用户添加到语音频道,而他们之前不在语音频道中 所以我有 lfg 模态代码:

class crowed(ui.Modal, title='Player Invite'):
    game = ui.TextInput(label='Game Invitation', placeholder='Rocket league, Apex Legends, etc.', style= discord.TextStyle.short, required=True)
    type = ui.TextInput(label = 'Game mode', placeholder='duo, 1v1, squads, etc.', style= discord.TextStyle.short, required=True)
    info = ui.TextInput(label=' Game Description', placeholder='no revives, all snipers, etc.', style= discord.TextStyle.long, required=False, default=f'There was no given information provided.')
    region = ui.TextInput(label='Game Region',placeholder='North America, Europe, etc.', style= discord.TextStyle.short, required=True)
    

    async def on_submit(self, interaction: discord.Interaction):
        category_name = "Games"  
        category = discord.utils.get(interaction.guild.categories, name=category_name)
        vc_name = f"{self.game} - {interaction.user.display_name}"
        vc = await category.create_voice_channel(vc_name)
        chicken = discord.Embed(title= f'Description: {self.info}', timestamp= datetime.now(), type='rich', color=discord.Color.random())
        chicken.add_field(name=' <:gg:1116420203308396556> Game',value=f'{self.game}', inline=True)
        chicken.add_field(name=f' <a:PP:1116409338630770769> Game Mode',value=f' {self.type}', inline=True)
        chicken.add_field(name=f' <a:sq:1116423925430222968> Region Type',value=f'{self.region}', inline=True)
        chicken.add_field(name=' <a:ds:1095220553540968578> VC/Lobby Space', value=f'{len(vc.members)}/{vc.user_limit} members in VC right now!')
        chicken.set_footer(text='use /invite to create your own game invite!', icon_url='https://art.pixilart.com/c4ec72c5f32b864.gif')
        invite = await vc.create_invite(max_age=0, max_uses=0, unique=True)
        chicken.add_field(name=f'**{vc.name} | {vc.category}** ', value=f'**[Click here to join]({invite.url})** ', inline=True)
        chicken.set_author(name=f' {interaction.user.display_name} is looking for party members!', icon_url=f'{interaction.user.guild.icon}', url = 'https://discord.com/users/' + str(interaction.user.id))
        chicken.set_thumbnail(url=f'{str(random.choice(listc))}')
        await interaction.response.send_message(embed=chicken)
        await interaction.user.edit(voice_channel=vc)
        await vc.set_permissions(interaction.user,manage_members=True,move_members=True,moderate_members=True)

正如你在上面看到的,我正在做

await interaction.user.edit(voice_channel=vc)
,但它给出了下面的错误。那么我怎样才能实现这个目标呢?

Traceback (most recent call last):
  File "C:\Users\trace\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\modal.py", line 188, in _scheduled_task
    await self.on_submit(interaction)
  File "c:\Users\trace\Desktop\MU LFG\lfg bot\lfg.py", line 37, in on_submit
    await interaction.user.edit(voice_channel=vc)
  File "C:\Users\trace\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\member.py", line 913, in edit
    data = await http.edit_member(guild_id, self.id, reason=reason, **payload)
  File "C:\Users\trace\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\http.py", line 745, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 40032): Target user is not connected to voice.
python discord discord.py
1个回答
0
投票

不幸的是,这不是一个功能,很可能永远不会通过不和谐来实现。这是一个安全问题,您只能移动频道中已有的人员。

© www.soinside.com 2019 - 2024. All rights reserved.