From c48b45d9bfc3621cdec870b55fd29c64bb08327e Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Fri, 13 Jan 2023 19:34:24 +0100 Subject: [PATCH] Read guild from config file --- bot.py | 8 ++++++-- config.json | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 config.json diff --git a/bot.py b/bot.py index e38b00f..8ebfe1d 100644 --- a/bot.py +++ b/bot.py @@ -12,6 +12,10 @@ import discord.utils BOOT_TIME = time.time() +config_file = open("config.json", "r") +config = json.loads(config_file.read()); +config_file.close() + def seconds_elapsed(): return time.time() - BOOT_TIME @@ -36,7 +40,7 @@ async def on_ready(): print('------') -@client.tree.command(guild=discord.Object(id=813127962881818624), name="change_hostname") +@client.tree.command(guild=discord.Object(id=config["guild"]), name="change_hostname") @app_commands.describe(distro='Assign yourself a role') async def distro(interaction: discord.Interaction, distro: typing.Literal[ 'LFS', 'Kiss', 'Gentoo', 'Void', 'NixOS', 'Alpine', @@ -174,7 +178,7 @@ async def distro(interaction: discord.Interaction, distro: typing.Literal[ # This context menu command only works on messages -@client.tree.context_menu(guild=discord.Object(id=813127962881818624), name='Report to Moderators') +@client.tree.context_menu(guild=discord.Object(id=config["guild"]), name='Report to Moderators') async def report_message(interaction: discord.Interaction, message: discord.Message): await interaction.response.send_message( f'Thanks for reporting this message by {message.author.mention} to our moderators.', ephemeral=True diff --git a/config.json b/config.json new file mode 100644 index 0000000..c93c520 --- /dev/null +++ b/config.json @@ -0,0 +1,8 @@ +{ + "guild": 750955881348464651, + "roles": { + "assign0": 1063506453308125274, + "assign1": 1063506544962064414 + }, + "report channel": 1063507041697677312 +}