更新时间:2023-01-26 20:23:32
该文档说 User
类具有用户ID:
http://discordpy.readthedocs.io/en/latest/api.html#user
The documentation says that the User
class have the user's id:
http://discordpy.readthedocs.io/en/latest/api.html#user
而成员
是 User
的子类:
http://discordpy.readthedocs.io/en/latest/api.html#member
因此,如果您收到用户发来的消息,则可以使用 message.author.id
获取ID。 p>
So if you got a message from a user, you can get the id with message.author.id
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
print(message.author.id)
client.run('token')