<tfoot id='CaXBx'></tfoot>
<legend id='CaXBx'><style id='CaXBx'><dir id='CaXBx'><q id='CaXBx'></q></dir></style></legend>

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

        • <bdo id='CaXBx'></bdo><ul id='CaXBx'></ul>

      1. <i id='CaXBx'><tr id='CaXBx'><dt id='CaXBx'><q id='CaXBx'><span id='CaXBx'><b id='CaXBx'><form id='CaXBx'><ins id='CaXBx'></ins><ul id='CaXBx'></ul><sub id='CaXBx'></sub></form><legend id='CaXBx'></legend><bdo id='CaXBx'><pre id='CaXBx'><center id='CaXBx'></center></pre></bdo></b><th id='CaXBx'></th></span></q></dt></tr></i><div id='CaXBx'><tfoot id='CaXBx'></tfoot><dl id='CaXBx'><fieldset id='CaXBx'></fieldset></dl></div>
      2. 让 VoiceChannel.members 和 Guild.members 返回完整列表的

        时间:2023-09-11

        <legend id='THUTf'><style id='THUTf'><dir id='THUTf'><q id='THUTf'></q></dir></style></legend>

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

                <tbody id='THUTf'></tbody>
                • <bdo id='THUTf'></bdo><ul id='THUTf'></ul>

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

                  本文介绍了让 VoiceChannel.members 和 Guild.members 返回完整列表的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  每当我尝试使用 VoiceChannel.members 或 Guild.members 时,它都不会为我提供适用成员的完整列表.我在这样的文本命令中从上下文中获取 VoiceChannel 和 Guild:

                  Any time I try to use VoiceChannel.members or Guild.members it does not give me a full list of applicable members. I'm grabbing both the VoiceChannel and the Guild from the context in a text command like this:

                  @bot.command(name='followme')
                  async def follow_me(ctx):
                      if ctx.author.voice != None:
                          guild = ctx.guild
                          tracking = ctx.author
                          channel = tracking.voice.channel
                  

                  后来我尝试使用这样的频道:

                  Later on I've tried to use the channel like this:

                  for member in channel.members:
                              if member.voice.mute != True:
                                  await member.edit(mute=True)
                  

                  但是,尽管频道中有其他用户,但它只能找到我的用户.

                  However, it's only finding my user despite having another user in the channel.

                  我发现在频道中获得准确代表的唯一方法是使用:

                  I found that the only way I could get an accurate representation of members in the channel is using:

                  channel.voice_states.keys()
                  

                  使用 voice_states,我可以获得准确的成员列表,但只有在我仍然需要操作成员本身时才能通过他们的 ID.所以我尝试了这个:

                  Using voice_states, I can get an accurate list of members, but only by their IDs when I still need to manipulate the member itself. So I tried this:

                  for key in channel.voice_states.keys():
                              member = guild.get_member(key)
                              if member.voice.mute != True:
                                  await member.edit(mute=True)
                  

                  然而,公会并没有拉出正确的用户组,尽管验证了所有 ID 都是正确的,但 guild.members 无法正常工作.

                  However, the guild isn't pulling the right set of users and despite verifying all the IDs were correct, guild.members is also not working appropriately.

                  任何关于如何使其正常工作的意见将不胜感激.

                  Any input on how to get this working properly would be greatly appreciated.

                  推荐答案

                  截至 10 月 7 日,Discord 已更改其 API,要求机器人声明 网关意图.确保您的 discord.py 至少更新到 1.5 版并启用成员意图:

                  As of October 7th, Discord has changed their API to require bots to declare gateway intents. Make sure your discord.py is updated to at least version 1.5 and enable the members intent:

                  import discord
                  from discord.ext import commands
                  
                  intents = discord.Intents.default()
                  intents.members = True 
                  
                  bot = commands.Bot(command_prefix='!', intents=intents)
                  

                  这篇关于让 VoiceChannel.members 和 Guild.members 返回完整列表的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将按钮组件添加到消息(discord.py) 下一篇:如何更改 discord.py 机器人活动

                  相关文章

                  最新文章

                    <tfoot id='jNvYd'></tfoot>

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

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

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