From be888fac87ce8526e768fe74750835782bede154 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sat, 12 Aug 2023 17:14:55 +1000 Subject: [PATCH] bot: Auto get admin id --- .env.example | 2 +- README.md | 2 +- bot.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index e6a6259..0effac4 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ DISCORD_TOKEN=MYTOKEN LINK_URL=https://l.woodburn.au LINK_API_KEY=MYAPIKEY -ADMIN_ID=DISCORDID +LOG_CHANNEL=MYCHANNELID diff --git a/README.md b/README.md index cba3097..1577d43 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This bot adds some Handshake related commands to the server. ## Docker The easiest way to run this bot is to use Docker. You can use the following command to run the bot: ```bash -docker run -d -e DISCORD_TOKEN= -e LINK_API_KEY= -e LINK_URL= -e ADMIN= -e LOG_CHANNEL= git.woodburn.au/nathanwoodburn/woodburn-bot:latest +docker run -d -e DISCORD_TOKEN= -e LINK_API_KEY= -e LINK_URL= -e LOG_CHANNEL= git.woodburn.au/nathanwoodburn/woodburn-bot:latest ``` ## Manual diff --git a/bot.py b/bot.py index 2d167ee..86d06ad 100644 --- a/bot.py +++ b/bot.py @@ -7,7 +7,7 @@ import dns.resolver load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') -ADMINID = int(os.getenv('ADMIN_ID')) +ADMINID = 0 KUTT_APIKEY=os.getenv('LINK_API_KEY') KUTT_URL=os.getenv('LINK_URL') LOG_CHANNEL = int(os.getenv('LOG_CHANNEL')) @@ -22,7 +22,6 @@ statusType="watching" # Commands @tree.command(name="ping", description="Check bot connection") async def ping(ctx): - await log("User: " + str(ctx.user.name) + " used the ping command") await ctx.response.send_message("Pong!",ephemeral=True) @tree.command(name="shortlink", description="Shorten a link") @@ -123,8 +122,11 @@ def updateStatus(): # When the bot is ready @client.event async def on_ready(): + global ADMINID + ADMINID = client.application.owner.id + await log("Bot is starting...") await tree.sync() - print("Ready!") updateStatus() + await log("Bot is ready") client.run(TOKEN) \ No newline at end of file