From 8d5b04a7e80f6b4f2aff029648d3aba55d0c781a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 11 Aug 2023 16:49:20 +1000 Subject: [PATCH] bot: Log to discord channel --- bot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 64063a8..23cb162 100644 --- a/bot.py +++ b/bot.py @@ -13,17 +13,21 @@ client = discord.Client(intents=intents) tree = app_commands.CommandTree(client) activityMessage="over the server" statusType="watching" +logChannel=1139449826287824996 # Commands @tree.command(name="ping", description="Check bot connection") async def ping(ctx): - print("Ping") + channel = client.get_channel(logChannel) + await channel.send("User: " + str(ctx.user.id) + " used ping command") await ctx.response.send_message("Pong!",ephemeral=True) @tree.command(name="shortlink", description="Shorten a link") async def shortlink(ctx, link: str, name: str = None): if (ctx.user.id != 892672018917519370): - print("User: " + str(ctx.user.id) + " tried to use the link command") + # Send a message in the log channel + channel = client.get_channel(logChannel) + await channel.send("User: " + str(ctx.user.id) + " tried to use the shortlink command") await ctx.response.send_message("You don't have permission to use this command",ephemeral=True) else: APIKEY=os.getenv('LINK_API_KEY') @@ -43,7 +47,8 @@ async def shortlink(ctx, link: str, name: str = None): @tree.command(name="botstatus", description="Set the bot status") async def botstatus(ctx, message: str, statusmethod: str = None): if (ctx.user.id != 892672018917519370): - print("User: " + str(ctx.user.id) + " tried to use the botstatus command") + channel=client.get_channel(logChannel) + await channel.send("User: " + str(ctx.user.id) + " tried to use the botstatus command") await ctx.response.send_message("You don't have permission to use this command",ephemeral=True) else: global activityMessage