首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Discord.py:如何使用discord.Profile.connected_accounts

Discord.py:如何使用discord.Profile.connected_accounts
EN

Stack Overflow用户
提问于 2020-12-09 23:48:48
回答 1查看 1.3K关注 0票数 0

我已经试着让它工作了几个小时了,我想让我的discord机器人简单地查看并返回目标账户有哪些连接的账户(YouTube,Twitch,Spotify等),我已经让它输出了一些东西,但我不能用它做任何事情;需要一个解决方案。

代码语言:javascript
复制
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"}‘

EN

回答 1

Stack Overflow用户

发布于 2020-12-10 00:05:51

这里引用的是类本身,而不是实例,user参数已经是一个discord.Member对象,您可以简单地这样做:

代码语言:javascript
复制
profile = await user.profile()
accounts = profile.connected_accounts

此外,机器人不能使用此功能

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65220127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档