打印好友列表以控制台Discord.py [英] Print friends-list to console Discord.py
本文介绍了打印好友列表以控制台Discord.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何打印以管理所有朋友的清单?
我希望能够通过Discord.py库实现这一目标,希望这里的人知道。
How would I go about printing to console a list of all my friends? I'm hoping to be able to achieve this with the Discord.py library, hopefully someone here knows.
我目前收到错误消息:
用于discord.ClientUser.friends中的用户:TypeError:'property'对象不可迭代
I currently get the error:
for user in discord.ClientUser.friends: TypeError: 'property' object is not iterable
程序:
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 ("Friends")
@bot.command()
async def userlist(ctx):
for user in discord.ClientUser.friends:
print (user.name+"#"+user.discriminator)
bot.run(token, bot=False)
推荐答案
discord.ClientUser
是一个类。您需要代表机器人用户帐户的 ClientUser
实例。您可以通过 bot.user获取此信息
,如命令。Bot
是 Client
discord.ClientUser
is a class. You want the ClientUser
instance that represents your bots user account. You can get this with bot.user
, as commands.Bot
is a subclass of Client
@bot.command()
async def userlist(ctx):
for user in bot.user.friends:
print (user.name+"#"+user.discriminator)
这篇关于打印好友列表以控制台Discord.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文