Added command logging to console

kami_dev
Kami 2025-02-02 00:29:58 +01:00
parent 1bc5d5c042
commit dd05c26b5d
2 changed files with 19 additions and 2 deletions

View File

@ -22,6 +22,10 @@ class DiscordBot(commands.Bot):
except Exception as e:
self.log(f"Error loading Discord commands: {e}", "ERROR")
async def on_command(self, ctx):
"""Logs every command execution at DEBUG level."""
self.log(f"Command executed: {ctx.command} by {ctx.author} in #{ctx.channel}", "DEBUG")
async def on_ready(self):
self.log(f"Discord bot is online as {self.user}", "INFO")

View File

@ -27,6 +27,21 @@ class TwitchBot(commands.Bot):
# 2) Then load commands
self.load_commands()
async def event_message(self, message):
"""Logs and processes incoming Twitch messages."""
if message.echo:
return # Ignore bot's own messages
# Log the command if it's a command
if message.content.startswith("!"):
self.log(f"Command executed: {message.content} by {message.author.name} in #{message.channel.name}", "DEBUG")
# Process the message for command execution
await self.handle_commands(message)
async def event_ready(self):
self.log(f"Twitch bot is online as {self.nick}", "INFO")
async def refresh_access_token(self):
"""
Refreshes the Twitch access token using the stored refresh token.
@ -106,8 +121,6 @@ class TwitchBot(commands.Bot):
Run the Twitch bot, refreshing tokens if needed.
"""
try:
self.log(f"Twitch bot connecting...", "INFO")
self.log(f"...Consider online if no further messages", "INFO")
await self.start()
#while True:
# await self.refresh_access_token()