Skip to content Skip to sidebar Skip to footer

Add Cooldown To Command[discord.py]

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 t

Solution 1:

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.

Post a Comment for "Add Cooldown To Command[discord.py]"