Reputation: 13
This might be a duplicated question! sorry I couldn't find an answer!
I have a bot running on a linux server "using discord python lib". I want trigger a command from the server side as a cronjob. Is that possible with the way Discord events are designed? The command needs to run every 5 mins!
I have a db with user/payment data. The command should check if the userid has sent payment. If so then assign them a specific role. Otherwise if the user's payment data is false remove the role.
Right now this works fine with a command I wrote "update_payment" however this command has to be triggered from the discord server manually. I don't want to run this by hand every 5 mins. How do I trigger it from a cronjob on the linux server?
Upvotes: 1
Views: 386
Reputation: 2917
You can use tasks.loop
to loop your task:
from discord.ext import tasks
@tasks.loop(minutes=5)
async def update_payment():
pass # whatever here
update_payment.start()
Upvotes: 1