![](/img/trans.png)
[英]Discord.py how to get the snowflake of a user that isn't a member of the server?
[英]Discord.py how to ban a user that isn't a member
user=get(ctx.guild.members, name="nameUser")
await ctx.guild.ban(user, reason=None)
這是我正在使用的代碼,我正在幫助一個朋友創建一個新的不和諧服務器,但他希望在這兩個服務器上擁有相同的禁止用戶。 我正在嘗試這樣做,但我只收到該錯誤: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
。 預先感謝您的任何幫助。
用戶 ID 是與用戶關聯的雪花整數,請訪問此支持帖子以了解如何找到它
# Use fetch user if the account is not in a guild with the bot
user = await bot.fetch_user(user_id)
await ctx.guild.ban(user, reason="Testing", delete_message_days=0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.