【发布时间】:2020-02-28 05:54:45
【问题描述】:
当我使用 ctx.guild.text_channels 并打印我分配给它的变量时,它只显示不和谐服务器中的第一个文本通道
如果我必须使用某种循环但找不到任何循环,我已经尝试查看不和谐重写的文档。所以我相信我做错了什么。
只是为了告诉你们我有会员:discord.Member,因为我稍后会使用它。
Discord 公会频道列表:http://prntscr.com/prdcaa
@bot.command(pass_contect=True)
async def check_client_channel(ctx, member: discord.Member):
channels = discord.utils.get(ctx.guild.text_channels)
print(channels)
channel_name = member.display_name + "-" + member.discriminator
我执行函数时的结果:
test2
预期结果:(类似于)
["test2", "general", "test", "testing-2611"]
【问题讨论】:
-
来自文档 -
A helper that returns the first element in the iterable that meets all the traits passed in attrs。这意味着utils.get只会返回一个值。ctx.guild.text_channels已经是一个包含文本通道的可迭代对象,因此您无需使用.get
标签: python discord discord.py-rewrite