Discord.py how to get the snowflake of a user that isn't a member of the server?

烂漫一生 提交于 2020-03-26 04:05:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!