我已经试着让它工作了几个小时了,我想让我的discord机器人简单地查看并返回目标账户有哪些连接的账户(YouTube,Twitch,Spotify等),我已经让它输出了一些东西,但我不能用它做任何事情;需要一个解决方案。
import discord
from discord import Intents, Profile
from discord.ext import commands
client = commands.bot(command_prefix = '!', intents = Intents.all())
token = 'abc123asdfghjkl;...'
@client.command()
async def hl(ctx, user: discord.Member = None):
if user is None:
user = ctx.author
accounts = discord.user.Profile.connected_accounts
print(accounts)
client.run(token)输出:'<_collections._tuplegetter object at 0x000001C807BB9370>‘
下面是我正在使用的库的文档:https://discordpy.readthedocs.io/en/latest/api.html#discord.Profile.connected_accounts
它说它返回一个字典列表,但我不知道如何处理它输出的tuplegetter对象,我希望它能输出这样的东西:
'{"type":"twitch","id":"92473777","name":"discordapp"}‘
发布于 2020-12-10 00:05:51
这里引用的是类本身,而不是实例,user参数已经是一个discord.Member对象,您可以简单地这样做:
profile = await user.profile()
accounts = profile.connected_accounts此外,机器人不能使用此功能
https://stackoverflow.com/questions/65220127
复制相似问题