Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zztkm/discordpy-logging-handler
https://github.com/zztkm/discordpy-logging-handler
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zztkm/discordpy-logging-handler
- Owner: zztkm
- Created: 2022-01-07T07:07:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T02:32:23.000Z (almost 3 years ago)
- Last Synced: 2024-12-20T23:29:47.830Z (14 days ago)
- Language: Python
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WIP: discordpy-logging-handler
Forward Discord bot logs to Discord Text channel.
## Install
```shell
pip install -U discord.py
``````shell
pip install discordpy-logging-handler
```## Usage
```python
import loggingimport discord
from discordpy_logging_handler import DiscordBotHandlerLOG_TEXT_CHANNEL_ID = 1111111111111
logger = logging.getLogger(__name__)
class MyClient(discord.Client):
async def on_ready(self):
logger.info("Logged on as {0}!".format(self.user))async def on_message(self, message):
logger.info("Message from {0.author}: {0.content}".format(message))client = MyClient()
client.run("my token goes here")log_channel = client.get_channel(LOG_TEXT_CHANNEL_ID)
logger.setLevel(logging.DEBUG)handler = DiscordBotHandler(log_channel)
handler.setLevel(logging.INFO)# add ch to logger
logger.addHandler(handler)
```