Add cooldown to command[Discord.py]

后端 未结 1 1960
夕颜
夕颜 2021-01-23 17:24

I started learning python recently and don’t understand how to make a cooldown for a command.I need the user to get coins every 12 hours. If the time has not passed yet, I need

相关标签:
1条回答
  • 2021-01-23 18:05

    You need to use this line above the command: @commands.cooldown(1, 43200, commands.BucketType.user).

    So you get:

    @commands.cooldown(1, 43200, commands.BucketType.user)
    @commands.command(name='daily')
        async def daily(self, ctx):
            with open('files/users_info.json', 'r') as f:
                users = json.load(f)
    

    Where 1 is the amount of times you can call the command per interval, 43200 (60*60*12) is the interval in seconds and commands.buckettype.user defines that the restriction is per user.

    0 讨论(0)
提交回复
热议问题