I am fairly new to programming. I've been trying to create a discord bot with the sole purpose of the bot messaging in chat when a specific user is talking. My code works but i want to add a cooldown timer so it is not happening everytime the user talks (otherwise it would be very annoying!)
I have tried to use @commands.cooldown(1, 1000, commands.BucketType.user)
but I understand it is only for commands and not events. I have spent a while trying to research what to code to use but I'm really struggling. Does anybody have any suggestions? Many thanks.
@bot.event
@commands.cooldown(1, 1000, commands.BucketType.user)
async def on_message(message):
if message.author == bot.user:
return
if message.author.id == XXXXXXX40387821569:
await message.channel.send('Haaaaaaaaaaaarrrryyyyy!')