我正试图让我的机器人禁止发送“ $ pull”消息的人,如果他们在randint(1,6)中得到1。
chamber = randint(1,6)
if chamber == 1:
await message.channel.send("%s got hoodbridged" % message.author)
game_active = False
这就是我所拥有的,但是如果房室== 1,我也试图使其禁止该人。谢谢!
答案 0 :(得分:1)
我相信您正在寻找的是Member.ban()。您可以详细了解in the docs here
要使用on_message:
@client.event
async def on_message(message):
if message.content.startswith('$pull'):
chamber = randint(1,6)
if chamber == 1:
await message.channel.send("%s got hoodbridged" % message.author)
await message.author.ban()
如果要使用discord.commands.Bot类来使用命令,则它看起来像这样:
prefix = "$"
client = commands.Bot(command_prefix=prefix)
@client.command(pass_context=True)
async def pull(ctx):
chamber = randint(1,6)
if chamber == 1:
await ctx.channel.send("%s got hoodbridged" % ctx.author)
await ctx.author.ban()