这是我的代码:
@bot.command()
async def list(ctx):
guild = ctx.guild
members = '\n - '.join([member.name for member in guild.fetch_members])
await ctx.send(f'Guild Members:\n - {members}')
我也试过 guild.members 但不起作用,这是错误
The Command raised an exception: TypeError: 'method' object is not iterable. Please, use a valid command.
答案 0 :(得分:0)
list
是python中的关键字,用户自定义函数尽量不要使用。
这是您可以用来获取带有序列号的成员的代码:
@bot.command()
async def memberlist(ctx):
members = ''
for index, member in enumerate(ctx.guild.members, start=1):
members += f'{index}) {member}\n'
await ctx.send(members)