我该如何打印以控制台服务器中的用户列表,不包括那些拥有默认/空头像的用户?我当前的代码看起来像这样,但不起作用。它打印的是用户列表,但不排除那些拥有默认头像的用户。这是在使用不和.py重写。在
#!/usr/bin/python
token = ""
prefix = "?"
import discord
import asyncio
import codecs
import sys
import io
from discord.ext import commands
from discord.ext.commands import Bot
print ("waiting")
bot = commands.Bot(command_prefix=prefix, self_bot=True)
bot.remove_command("help")
@bot.event
async def on_ready():
print ("users with avatars")
@bot.command(pass_context=True)
async def userlist(ctx):
for user in list(ctx.message.guild.members):
if user.avatar == None:
pass
else:
for user in list(ctx.message.guild.members):
print (user.name+"#"+user.discriminator)
bot.run(token, bot=False)
当用户的头像为空时,}。
尝试查找当用户的化身为空时,
user.avatar
可能不会返回{user.avatar
返回的值。在User
s还有一个^{User.avatar
进行比较,您应该能够筛选出与之匹配的用户。在这是假设您的真正问题不是您在
^{pr2}$else
内再次循环所有成员。尝试以下解决方案:相关问题 更多 >
编程相关推荐