Closed gfldex closed 3 years ago
I would like to add that this is the first PR do help with logging. Having a lib/Discrod/Debug.rakumod
is a precondition for things to follow.
2nd part is now done. The user can divert output to $*ERR to a Supply and do some filtering via:
use API::Discord::Debug;
react whenever debug-say().merge(debug-print()) {
when HEARTBEAT { $*ERR.print: $_ }
when CONNECTION { note now.Datetime.Str, ' ', $_ }
when /your term here/ { .&do-stuff() }
default {}
}
This allows to deal with error messages in the main react block. All symbols can be kept lexical to avoid collision with other modules. The raku-bot is using this now in the following fassion, which works nicely.
start react {
whenever $discord.messages -> $message {
next unless $channels ~~ $message.channel.name;
$result.emit: [ $message.channel.&augment, $message.author.&augment, $message.content ];
}
# [...]
{
use API::Discord::Debug;
whenever debug-say().merge(debug-print()) {
when HEARTBEAT { }
default { .note }
}
}
}
Thanks for your contribution, I will try and get around to testing this either tomorrow or Monday and look to getting it merged during the week hopefully.
see: https://gfldex.wordpress.com/2021/06/23/being-pragmat-ish/