【问题标题】:get a list of members in a vc discord.py获取 vc discord.py 中的成员列表
【发布时间】:2021-07-03 12:16:21
【问题描述】:

我尝试了this中的所有代码

但我目前的代码似乎不起作用,你能帮帮我吗? [如果有可能你甚至可以ping通会员吗?]

@client.command()
async def test(ctx, *, name):
  ce_channel = discord.utils.get(ctx.message.guild.channels, name=name,type=discord.ChannelType.voice)
  lel = ce_channel.members
  for member in lel:
   await ctx.send(member.name)

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    如果您遍历公会语音频道而不是所有频道,则无需指定频道类型:

    @client.command()
    async def get_vcmembers(ctx, name):
        vchannel = discord.utils.get(
            ctx.guild.voice_channels, name=name
        )
        for mem in vchannel.members:
            await ctx.channel.send(member.mention)
    

    member.mention 属性是一个字符串,允许您提及(ping)该成员。

    【讨论】:

      猜你喜欢
      • 2019-12-29
      • 1970-01-01
      • 2021-04-24
      • 2021-12-17
      • 1970-01-01
      • 2021-10-16
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多