<i id='FCiIL'><tr id='FCiIL'><dt id='FCiIL'><q id='FCiIL'><span id='FCiIL'><b id='FCiIL'><form id='FCiIL'><ins id='FCiIL'></ins><ul id='FCiIL'></ul><sub id='FCiIL'></sub></form><legend id='FCiIL'></legend><bdo id='FCiIL'><pre id='FCiIL'><center id='FCiIL'></center></pre></bdo></b><th id='FCiIL'></th></span></q></dt></tr></i><div id='FCiIL'><tfoot id='FCiIL'></tfoot><dl id='FCiIL'><fieldset id='FCiIL'></fieldset></dl></div>

      <bdo id='FCiIL'></bdo><ul id='FCiIL'></ul>
  1. <tfoot id='FCiIL'></tfoot><legend id='FCiIL'><style id='FCiIL'><dir id='FCiIL'><q id='FCiIL'></q></dir></style></legend>
  2. <small id='FCiIL'></small><noframes id='FCiIL'>

    1. 如何使用 discord.py 获取语音频道的所有成员

      时间:2023-10-11

        <small id='8UrwI'></small><noframes id='8UrwI'>

          <i id='8UrwI'><tr id='8UrwI'><dt id='8UrwI'><q id='8UrwI'><span id='8UrwI'><b id='8UrwI'><form id='8UrwI'><ins id='8UrwI'></ins><ul id='8UrwI'></ul><sub id='8UrwI'></sub></form><legend id='8UrwI'></legend><bdo id='8UrwI'><pre id='8UrwI'><center id='8UrwI'></center></pre></bdo></b><th id='8UrwI'></th></span></q></dt></tr></i><div id='8UrwI'><tfoot id='8UrwI'></tfoot><dl id='8UrwI'><fieldset id='8UrwI'></fieldset></dl></div>
            <tbody id='8UrwI'></tbody>
            • <bdo id='8UrwI'></bdo><ul id='8UrwI'></ul>
              1. <legend id='8UrwI'><style id='8UrwI'><dir id='8UrwI'><q id='8UrwI'></q></dir></style></legend>

                <tfoot id='8UrwI'></tfoot>
                本文介绍了如何使用 discord.py 获取语音频道的所有成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有问题,如果我将所有成员作为特定语音频道的 Meber 的对象.我只得到一个空列表.

                I have the problem, if I will get all members as an object of Meber of a specific Voice-channel. I only get a empty list back.

                这是我的代码:

                @bot.command(name='random')
                async def nine_nine(ctx, amount_of_groups: int):
                    this_guild = ctx.guild
                    sender = ctx.message.author
                    #Es wird geschaut, in welchem Channel sich der Schreiber befindet
                    try:
                        voice_channel = ctx.message.author.voice.channel
                        print(voice_channel)
                    except AttributeError:
                        await ctx.send("Du bist in keinem Voice-Channel")
                        return
                    #Alle anderen Mitglieder aus dem Kanal werden ermittelt und in eine Liste geschrieben
                    this_category = voice_channel.category
                
                    member_list = voice_channel.members # <-- This only returns an empty List
                
                    print(member_list)
                    print(this_category)
                    #Die Mitglieder werden gemischt
                    random.shuffle(member_list)
                    #Die Mitglieder werden in gleichgroße Gruppen aufgeteilt
                    avg = len(member_list) / float(amount_of_groups)
                    out = []
                    last = 0.0
                
                    while last < len(member_list):
                        out.append(member_list[int(last):int(last + avg)])
                        last += avg
                    print(out)
                    for group in range(0, amount_of_groups):
                        new_channel = await this_guild.create_voice_channel(name=f'Gruppe{group+1}', category=this_category)
                        for member in range(len(out[group])):
                            try:
                                await out[group][member].move_to(new_channel)
                            except:
                                print("F")
                            print(out[group][member])
                
                

                我该如何解决这个问题?

                How can I fix this Problem?

                推荐答案

                你必须像这样在 bot = ... 之前启用 Intents.members:

                You have to enable Intents.members like this before bot = ... :

                intents = discord.Intents.default()
                intents.members = True
                

                并更新 bot = .. 以包含参数 intents=intents.

                and update the bot = .. to include the argument intents=intents.

                您还必须在您的应用程序站点中启用不和谐的成员意图(

                Also you have to enable member intents in your application site in discord (go here, click on your bot, click on bot at the sidebar and enable them.):

                参考资料:

                discord.Intents.members

                这篇关于如何使用 discord.py 获取语音频道的所有成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 discord.py rewrite 中获取成员数? 下一篇:在 discord.py 中播放音轨队列

                相关文章

                最新文章

                • <bdo id='zVNmg'></bdo><ul id='zVNmg'></ul>
                <legend id='zVNmg'><style id='zVNmg'><dir id='zVNmg'><q id='zVNmg'></q></dir></style></legend>

                <small id='zVNmg'></small><noframes id='zVNmg'>

                1. <i id='zVNmg'><tr id='zVNmg'><dt id='zVNmg'><q id='zVNmg'><span id='zVNmg'><b id='zVNmg'><form id='zVNmg'><ins id='zVNmg'></ins><ul id='zVNmg'></ul><sub id='zVNmg'></sub></form><legend id='zVNmg'></legend><bdo id='zVNmg'><pre id='zVNmg'><center id='zVNmg'></center></pre></bdo></b><th id='zVNmg'></th></span></q></dt></tr></i><div id='zVNmg'><tfoot id='zVNmg'></tfoot><dl id='zVNmg'><fieldset id='zVNmg'></fieldset></dl></div>

                    <tfoot id='zVNmg'></tfoot>