From 3aa1149b10e780b3420ec16036eecaaa247bfa90 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Mon, 11 Sep 2023 21:24:23 +0200 Subject: [PATCH] QoL: Automatically create bot invite URLs (#74) * Automatically create an invite_url * Change invite url log message --- robocop_ng/__main__.py | 13 ++++++++++++- robocop_ng/config_template.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/robocop_ng/__main__.py b/robocop_ng/__main__.py index b24b912..b9f780d 100755 --- a/robocop_ng/__main__.py +++ b/robocop_ng/__main__.py @@ -257,9 +257,20 @@ for wanted_json in wanted_jsons: async def main(): async with bot: + if len(config.guild_whitelist) == 1: + invite_url = discord.utils.oauth_url( + config.client_id, + guild=discord.Object(config.guild_whitelist[0]), + disable_guild_select=True, + ) + else: + invite_url = discord.utils.oauth_url(config.client_id) + + log.info(f"\nInvite URL: {invite_url}\n") + for cog in config.initial_cogs: try: - await bot.load_extension(cog) + await bot.load_extension(f"robocop_ng.{cog}") except Exception as e: log.exception(f"Failed to load cog {cog}:", e) await bot.start(config.token) diff --git a/robocop_ng/config_template.py b/robocop_ng/config_template.py index 4bedbd2..ab492e6 100644 --- a/robocop_ng/config_template.py +++ b/robocop_ng/config_template.py @@ -3,6 +3,7 @@ import hashlib # Basic bot config, insert your token here, update description if you want prefixes = [".", "!"] +client_id = 0 token = "token-goes-here" bot_description = "Robocop-NG, the moderation bot of ReSwitched."