Answer the question
In order to leave comments, you need to log in
Is it possible to send all errors from the compiler to some channel?
I want to log all bot errors and send them to some channel, I know how to send them to the channel, but I don’t understand how to log everything, like the function only reacts to errors when the user writes a command, but how to log an error inside the bot?
ps it's all in classasync def on_command_error
from discord.ext.commands import Bot as BotBase
class Bot(BotBase):
...
Answer the question
In order to leave comments, you need to log in
You need to do this with a separate bot, or better not even with a bot, but just pull the API with a curl and send log messages there.
It is better not to do this from the bot itself, especially when it comes to unexpected errors.
Expected (regular) errors can be sent from the same instance where the bot is running.
So, connect the standard logging, set up a separate handler that filters the required level of messages, set up the formatter. to format a full error report.
You can look for a ready-made lib of such a handler, it is probably in pipy, or you can get confused yourself.
But you need to be careful. You need to understand that some errors, especially if they are processed incorrectly, can fall out very, very often, which is why your bot that posts these errors will simply be banned.
UPD/
As I said, there are a lot of ready-made handlers:
https://pypi.org/project/python-telegram-handler/
https://pypi.org/project/python-telegram-logger/
https://pypi.org /project/logging2telegram/
https://pypi.org/project/tglogger/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question