bot that write in a channel every hour

Posted in General by kolam Sat Aug 08 2020 00:07:57 GMT+0000 (Coordinated Universal Time)·2·Viewed 135 times

i need to create a bot that every hour sends a image to a channel with the hour in a pic. how can i do that?
Aug 28, 2020

I had a similar requirement and ended up using Restcord for that. I've got DiscordPHP handling my realtime interactions in my code but for scheduled stuff, restcord.com was easier because I couldn't figure out a way to do DiscordPHP stuff without it being a reaction to an event.

Sep 14, 2020

Quick an dirty hack to expose the loop in the userspace and use it to hook some code periodically

class myDiscord extends Discord {
function getLoop() {
return $this->loop;
}
}

$this->discord = new myDiscord([
'token' => $this->token,
]);
$this->discord->on('ready', function ($discord) {
$this->discord->getLoop()->addPeriodicTimer(5, function () { //every 5s
$memory = memory_get_usage() / 1024;
$formatted = number_format($memory, 3).'K';
echo "Current memory usage: {$formatted}\n";
});
$this->discord->on('message', function ($message, $discord) {
$this->handle($message);
});
});
$this->discord->run();

  
Markdown is allowed