log whenever joined/left a server

This commit is contained in:
DasMoorhuhn 2024-02-20 21:55:27 +01:00
parent b9f87e853d
commit 03356e28a6
2 changed files with 34 additions and 2 deletions

View File

@ -1,6 +1,27 @@
# IT Discord Bot
# Tux Bot
This is just a little fun bot. It can give you an excuse, if you're stuck while programming.
## Getting started
Create a file calles `secret.json` in the directory, where the `docker-compose.yml` file is. Put there your discord bot token in:
```json
{
"BOT_TOKEN": "YOUR_TOKEN"
}
```
And start the discord bot with:
```shell
docker-compose up --build
```
For getting the right invite link with the right permissions, run:
```shell
python3 create_invite_link.py YOUR_BOTS_ID
```
You can get the ID from the developer portal or from the terminal log while starting the discord bot
## Privacy
The discord bot will only log, whenever a command was called and whenever the bot was added or removed from a discord server. It won't log any user/server specific information.

View File

@ -3,6 +3,7 @@ import asyncio
import os
import discord
from discord import Guild
from discord import app_commands
from discord import Interaction
@ -31,6 +32,16 @@ async def load_cogs():
await bot.load_extension(f"cogs.{filename[:-3]}")
@bot.event
async def on_guild_join(guild: Guild):
logger.info("Joined guild")
@bot.event
async def on_guild_remove(guild: Guild):
logger.info("Left guild")
@bot.event
async def on_ready():
logger.info(f"Logged in as: {bot.user.name} with ID {bot.user.id}")