From 0aade0c6fdbc59c0f025b45da3fa597b409b3487 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Fri, 13 Jan 2023 20:31:53 +0100 Subject: [PATCH] Make things actually work + minor improvement of ststus command though that will be revised soon anyway --- bot.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 8ebfe1d..67c1172 100644 --- a/bot.py +++ b/bot.py @@ -17,7 +17,7 @@ config = json.loads(config_file.read()); config_file.close() def seconds_elapsed(): - return time.time() - BOOT_TIME + return int(time.time() - BOOT_TIME) class MyClient(discord.Client): @@ -40,7 +40,7 @@ async def on_ready(): print('------') -@client.tree.command(guild=discord.Object(id=config["guild"]), name="change_hostname") +@client.tree.command(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', @@ -48,6 +48,10 @@ async def distro(interaction: discord.Interaction, distro: typing.Literal[ 'OpenSuSE', 'Debian', 'Debian based', 'Solus', 'Fedora', 'Ubuntu', 'Ubuntu Based', 'BSD', 'MacOS', 'Windows' ]): + if not interaction.guild.id==config["guild"]: + print("Role assignment attempted from unknown guild.") + return + user = interaction.user if distro == 'LFS': user = interaction.user @@ -178,8 +182,10 @@ 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=config["guild"]), name='Report to Moderators') +@client.tree.context_menu(name='Report to Moderators') async def report_message(interaction: discord.Interaction, message: discord.Message): + if not interaction.guild.id==config["guild"]: + return await interaction.response.send_message( f'Thanks for reporting this message by {message.author.mention} to our moderators.', ephemeral=True ) @@ -201,6 +207,7 @@ async def status(interaction: discord.Interaction): System: {sys.platform}""" url_view = discord.ui.View() await interaction.response.send_message(embed=embed, view=url_view) + print("Status queried.") client.run(sys.argv[1])