Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5315e11
Rewrite Message Edit Logging
ajax146 Jun 9, 2026
13a4c53
Update message edit docstring
ajax146 Jun 9, 2026
6e60142
Sort the events.py file a bit
ajax146 Jun 9, 2026
ee59a2a
Delete message events
ajax146 Jun 9, 2026
0769590
bulk message delete rewritten
ajax146 Jun 9, 2026
3887b8b
Reaction add and remove done
ajax146 Jun 9, 2026
99263d1
Reaction clear done
ajax146 Jun 9, 2026
6e7370a
Work more on better events
ajax146 Jun 10, 2026
7939009
Standardize functions
ajax146 Jun 10, 2026
0838060
Poll vote add/remove
ajax146 Jun 10, 2026
29f3876
Do all the member events
ajax146 Jun 10, 2026
5e11367
AddMoreEvents
ajax146 Jun 11, 2026
66954c0
Merge branch 'main' into RewriteEvents
ajax146 Jun 11, 2026
8a1fbe0
Merge branch 'main' into RewriteEvents
ajax146 Jun 12, 2026
ca070b3
3 thread events, 2 invite events done
ajax146 Jun 12, 2026
6614812
Merge branch 'RewriteEvents' of github.com:r-Techsupport/TechSupportB…
ajax146 Jun 12, 2026
34e7705
Make some changes, move console only logs to bot.py
ajax146 Jun 12, 2026
a4cf98a
Soundboard events
ajax146 Jun 12, 2026
72134c0
Stickers and Emojis
ajax146 Jun 12, 2026
cbecada
Integration logging
ajax146 Jun 12, 2026
3422cc7
Add the rest of the events
ajax146 Jun 12, 2026
2386aea
Doc strings. So many doc strings
ajax146 Jun 12, 2026
c1df404
Update changelog
ajax146 Jun 12, 2026
e1be7d1
Formatting changes
ajax146 Jun 12, 2026
7139fe4
Formatting changes
ajax146 Jun 12, 2026
d81e353
Formatting changes
ajax146 Jun 12, 2026
c21fab4
minor formatting changes
ajax146 Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import glob
import io
import os
import sys
import threading
from typing import Self

Expand Down Expand Up @@ -181,13 +182,68 @@ async def setup_hook(self: Self) -> None:
self.extension_name_list = []
await self.load_extensions()

async def on_guild_remove(self: Self, guild: discord.Guild) -> None:
"""See: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_guild_remove

Args:
guild (discord.Guild): The guild that got removed
"""
await self.logger.send_log(
message=f"Left guild with ID {guild.id}",
level=LogLevel.INFO,
console_only=True,
)

async def on_error(self: Self, event_method: str) -> None:
"""Catches non-command errors and sends them to the error logger for processing.

Args:
event_method (str): the event method name associated with the error (eg. on_message)
"""
_, exception, _ = sys.exc_info()
await self.bot.logger.send_log(
message=f"Bot error in {event_method}: {exception}",
level=LogLevel.ERROR,
exception=exception,
)

async def on_connect(self: Self) -> None:
"""See: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_connect"""
await self.logger.send_log(
message="Connected to Discord",
level=LogLevel.INFO,
console_only=True,
)

async def on_resumed(self: Self) -> None:
"""See: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_resumed"""
await self.logger.send_log(
message="Resume connection to discord",
level=LogLevel.INFO,
console_only=True,
)

async def on_disconnect(self: Self) -> None:
"""See: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_disconnect"""
await self.logger.send_log(
message="Disconnected from Discord",
level=LogLevel.INFO,
console_only=True,
)

async def on_guild_join(self: Self, guild: discord.Guild) -> None:
"""Configures a new guild upon joining.
This registers a new guild config, and starts any loop jobs that are configured

Args:
guild (discord.Guild): the guild that was joined
"""
await self.logger.send_log(
message=f"Joined guild with ID {guild.id}",
level=LogLevel.INFO,
console_only=True,
)

for cog in self.cogs.values():
if getattr(cog, "COG_TYPE", "").lower() == "loop":
try:
Expand Down
20 changes: 12 additions & 8 deletions botlogging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ async def send_log(
console_only: bool = False,
embed: discord.Embed = None,
exception: Exception = None,
embed_as_is: bool = False,
) -> None:
"""A comprehensive logging system
This will log a message, embed, and/or exception to the console and discord
Expand All @@ -216,6 +217,8 @@ async def send_log(
exception (Exception, optional): The exception item if you wish to
log an exception with this log.
Exceptions will be logged in plain text. Defaults to None.
embed_as_is (bool, optional): If the passed embed should be sent without any edits
Defaults to False
"""
log_level = self.convert_level(level)

Expand All @@ -238,17 +241,18 @@ async def send_log(
if console_only or not self.send:
return

# Ensure message is never too long
if len(message) > 4000:
message = f"{message[:4000]}..."

# Get the appropriate target to send to on discord
log_channel = await self.get_discord_target(channel)

if embed:
embed = log_level.embed(message).modify_embed(embed)
else:
embed = log_level.embed(message)
if not embed_as_is:
# Ensure message is never too long
if len(message) > 4000:
message = f"{message[:4000]}..."

if embed:
embed = log_level.embed(message).modify_embed(embed)
else:
embed = log_level.embed(message)

try:
await log_channel.send(embed=embed)
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Changes since 2026.06.04

## Moderation

### Events
- Complete overhaul of events logging system. A huge number of additional events are now tracked, and information is displayed in a more readable way

### Logger
- Now mentions roles instead of listing text names

Expand Down
1 change: 1 addition & 0 deletions configuration/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"core_guild_id": "",
"core_logging_channel": "",
"core_member_events_channel": "",
"core_message_events_channel": "",
"core_nickname_filter": false,
"core_private_channels": [],
"duck_allow_manipulation": true,
Expand Down
6 changes: 5 additions & 1 deletion configuration/config.meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"core_guild_events_channel": {
"datatype": "discord.TextChannel",
"description": "The channel to log guild events to. This includes message events"
"description": "The channel to log guild events to."
},
"core_guild_id": {
"datatype": "discord.Guild",
Expand All @@ -95,6 +95,10 @@
"datatype": "discord.TextChannel",
"description": "The channel to log member events to."
},
"core_message_events_channel": {
"datatype": "discord.TextChannel",
"description": "The channel to log message events to."
},
"core_nickname_filter": {
"datatype": "bool",
"description": "Whether to run the nickname filter or not"
Expand Down
Loading
Loading