问题
username="Testing"
BADuser = await bot.fetch_user(username)
await ctx.guild.ban(BADuser, reason="Testing", delete_message_days=0)
This is the code I'm using. I get this error:
command raised an exception: HTTPException: 400 BAD REQUEST (error code: 50035): Invalid Form Body
In user_id: Value "Testing" is not snowflake.
I don't know how to get the snowflake using only the name and the unique number for each user. Cause the users aren't on the server. Thank you for any help.
回答1:
The bot cannot find the ID of a user it cannot access, you need the ID to access the user. You can view the docs for this call here, and this is the only call the library has that lets you access user data that the bot cannot directly communicate with
来源:https://stackoverflow.com/questions/60476913/discord-py-how-to-get-the-snowflake-of-a-user-that-isnt-a-member-of-the-server