Module discord_lumberjack.handlers.discord_dm_handler
Classes
class DiscordDMHandler (bot_token: str, user_id: int, level: int = 0, message_creator: MessageCreator = None)
-
A logging handler that sends messages to a Discord Direct Message Channel from a Bot.
Upon construction, this handler will attempt to create a DM channel with the user specified by the user_id argument. If this fails, the constructor will raise a ValueError.
Since a DM channel is a kind of channel, this handler is a subclass of DiscordChannelHandler.
Args
bot_token
:str
- The authentication token of the Bot to send the message with.
user_id
:int
- The ID of the user to send the message to.
level
:int
, optional- The level at which to log. Defaults to logging.NOTSET.
message_creator
:MessageCreator
, optional- An instance of MessageCreator or one of its subclasses that will be used to create the message to send from each log record. Defaults to one that sends messages in monospace.
Initializes the instance - basically setting the formatter to None and the filter list to empty.
Ancestors
- DiscordChannelHandler
- DiscordHandler
- logging.Handler
- logging.Filterer
Methods
def create_dm_channel(self, user_id: int, bot_token: str) ‑> int
-
Create a DM channel through the discord API.
Args
user_id
:int
- The ID of the user to create a DM channel with.
Returns
int
- The ID of the DM channel.
Raises
ValueError
- If the bot was unable to create a DM channel with the user.
Inherited members