Discord.py如何禁止不是会员的用户

时间:2020-02-29 14:52:04

标签: discord.py discord.py-rewrite

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'。预先感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

用户ID是与用户相关联的雪花整数,请访问this support post以了解如何找到它

# 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)