Python / Discord:仅阻止某些人访问命令

时间:2020-09-07 17:54:37

标签: python discord discord.py

我正在为不和谐的RPG设置角色创建者,并且我编写了一些代码来阻止某人(如果有人已经开始的话)启动角色创建者:

if message.content == "MMO start":
    if not currentcreator == 0:
        await message.channel.send("Someone is already making a profile so please wait")
    currentcreator = message.author

但是我无法解决在不取消第二人的情况下如何阻止第二人前进的情况?

1 个答案:

答案 0 :(得分:0)

尝试使用此:

character_creating = False

@bot.event
async def on_message(message):
    if message.content == "MMO start":
        if character_creating:
            await message.channel.send("Someone is already making a profile so please wait")
            return
        character_crearing = True
        

        #then do the character creating code here and at last do
        character_creating = False