我想做一个程序,将获得您输入的用户名的用户id。这是我到目前为止所知道的:
from discord.ext import commands
client = commands.Bot(description="a", command_prefix=".", self_bot = False)
client.remove_command('help')
@client.event
async def on_ready():
user = await client.fetch_user("pirace#4637")
print(user)
client.run('token')
它给出了这个错误:
400 Bad Request (error code: 50035): Invalid Form Body
In user_id: Value "pirace#4637" is not snowflake.
有人知道我会怎么做吗?
发布于 2021-04-26 21:15:33
如果您想使用用户名,则必须使用discord.utils.get()
,在本例中结合使用client.get_guild(GUILD_ID)
。
from discord.ext import commands
client = commands.Bot(description="a", command_prefix=".", self_bot = False)
client.remove_command('help')
@client.event
async def on_ready():
guild = client.get_guild(GUILD_ID)
user = discord.utils.get(guild.members, name="pirace", discriminator="4637")
print(user)
client.run('token')
https://stackoverflow.com/questions/67248017
复制相似问题