mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-03 00:23:13 +00:00
Logs on_application_command_completion
This commit is contained in:
parent
4b20840c42
commit
c7b2aacb37
2 changed files with 49 additions and 17 deletions
62
main.py
62
main.py
|
@ -9,6 +9,7 @@ SPECIAL_BALANCE_NAME=
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -98,19 +99,21 @@ def setup_logger():
|
||||||
logger.addHandler(info_file_handler)
|
logger.addHandler(info_file_handler)
|
||||||
|
|
||||||
logger.propagate = False
|
logger.propagate = False
|
||||||
|
logging.captureWarnings(True)
|
||||||
|
|
||||||
return logger
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
racu_logs = setup_logger()
|
||||||
|
|
||||||
|
|
||||||
@sbbot.event
|
@sbbot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
# wait until the bot is ready
|
racu_logs.info(f"Logged in as {sbbot.user.name}")
|
||||||
# then sync the sqlite3 database
|
racu_logs.info(f"discord.py API version: {discord.__version__}")
|
||||||
# db.tables.sync_database()
|
racu_logs.info(f"Python version: {platform.python_version()}")
|
||||||
# Item.insert_items()
|
racu_logs.info(f"Running on: {platform.system()} {platform.release()} ({os.name})")
|
||||||
|
racu_logs.info("-----------------------------------------")
|
||||||
# reload all cogs to sync db parameters
|
|
||||||
# load_cogs(reload=True)
|
|
||||||
racu_logs.info("RACU IS BOOTED/READY")
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
https://docs.pycord.dev/en/stable/api/events.html#discord.on_ready
|
https://docs.pycord.dev/en/stable/api/events.html#discord.on_ready
|
||||||
|
@ -124,11 +127,16 @@ async def on_message(message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
return
|
||||||
|
|
||||||
xp_handler = XPHandler()
|
try:
|
||||||
await xp_handler.process_xp(message)
|
xp_handler = XPHandler()
|
||||||
|
await xp_handler.process_xp(message)
|
||||||
|
|
||||||
reaction_handler = ReactionHandler(reactions)
|
reaction_handler = ReactionHandler(reactions)
|
||||||
await reaction_handler.handle_message(message)
|
await reaction_handler.handle_message(message)
|
||||||
|
|
||||||
|
except Exception as error:
|
||||||
|
racu_logs.error(f"on_message (check debug log): {error}", exc_info=False)
|
||||||
|
racu_logs.debug(f"on_message (w/ stacktrace): {error}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
@sbbot.event
|
@sbbot.event
|
||||||
|
@ -159,7 +167,35 @@ async def on_member_join(member):
|
||||||
await guild.get_channel(welcome_channel_id).send(embed=embed, content=member.mention)
|
await guild.get_channel(welcome_channel_id).send(embed=embed, content=member.mention)
|
||||||
|
|
||||||
|
|
||||||
racu_logs = setup_logger()
|
@sbbot.event
|
||||||
|
async def on_application_command_completion(ctx) -> None:
|
||||||
|
"""
|
||||||
|
This code is executed when a slash_command has been successfully executed.
|
||||||
|
:param ctx:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
full_command_name = ctx.command.qualified_name
|
||||||
|
split = full_command_name.split(" ")
|
||||||
|
executed_command = str(split[0])
|
||||||
|
|
||||||
|
if ctx.guild is not None:
|
||||||
|
racu_logs.info(
|
||||||
|
f"Executed {executed_command} command in {ctx.guild.name} (ID: {ctx.guild.id}) "
|
||||||
|
f"by {ctx.author} (ID: {ctx.author.id})"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
racu_logs.info(
|
||||||
|
f"Executed {executed_command} command by {ctx.author} (ID: {ctx.author.id}) in DMs."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# async def on_application_command_error(ctx, error) -> None:
|
||||||
|
# racu_logs.error(f"on_command_error (check debug log): {error}", exc_info=False)
|
||||||
|
# racu_logs.debug(f"on_command_error (w/ stacktrace): {error}", exc_info=True)
|
||||||
|
|
||||||
|
# async def on_error(event: str, *args, **kwargs) -> None:
|
||||||
|
# racu_logs.error(f"on_command_error (check debug log): {event}")
|
||||||
|
|
||||||
|
|
||||||
# load all json
|
# load all json
|
||||||
strings = json_loader.load_strings()
|
strings = json_loader.load_strings()
|
||||||
|
|
|
@ -23,7 +23,6 @@ class BasicCog(commands.Cog):
|
||||||
async def ping(self, ctx):
|
async def ping(self, ctx):
|
||||||
ping = round(self.bot.latency * 1000, 2)
|
ping = round(self.bot.latency * 1000, 2)
|
||||||
await ctx.respond(f"SB latency: {ping} ms")
|
await ctx.respond(f"SB latency: {ping} ms")
|
||||||
racu_logs.info(f"{ctx.author.name} used the ping command. | ping: {ping} ms")
|
|
||||||
|
|
||||||
@commands.slash_command(
|
@commands.slash_command(
|
||||||
name="restart",
|
name="restart",
|
||||||
|
@ -33,7 +32,6 @@ class BasicCog(commands.Cog):
|
||||||
@commands.check(universal.owner_check)
|
@commands.check(universal.owner_check)
|
||||||
async def restart(self, ctx):
|
async def restart(self, ctx):
|
||||||
await ctx.respond(content="Restarting..", ephemeral=True)
|
await ctx.respond(content="Restarting..", ephemeral=True)
|
||||||
racu_logs.info(f"{ctx.author.name} used the restart command.")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
racu_logs.info(subprocess.check_output(["/bin/bash", "racu_update.sh"]))
|
racu_logs.info(subprocess.check_output(["/bin/bash", "racu_update.sh"]))
|
||||||
|
@ -47,8 +45,6 @@ class BasicCog(commands.Cog):
|
||||||
)
|
)
|
||||||
@commands.dm_only()
|
@commands.dm_only()
|
||||||
async def intro(self, ctx):
|
async def intro(self, ctx):
|
||||||
racu_logs.info(f"{ctx.author.name} used the intro command.")
|
|
||||||
|
|
||||||
guild_id = 719227135151046699
|
guild_id = 719227135151046699
|
||||||
channel_id = 973619250507972618
|
channel_id = 973619250507972618
|
||||||
muted_role_id = 754895743151505489
|
muted_role_id = 754895743151505489
|
||||||
|
|
Loading…
Reference in a new issue