Make things actually work

+ minor improvement of ststus command though that will be revised soon anyway
pull/2/head
BodgeMaster 2023-01-13 20:31:53 +01:00
parent c48b45d9bf
commit 0aade0c6fd
1 changed files with 10 additions and 3 deletions

13
bot.py
View File

@ -17,7 +17,7 @@ config = json.loads(config_file.read());
config_file.close() config_file.close()
def seconds_elapsed(): def seconds_elapsed():
return time.time() - BOOT_TIME return int(time.time() - BOOT_TIME)
class MyClient(discord.Client): class MyClient(discord.Client):
@ -40,7 +40,7 @@ async def on_ready():
print('------') 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') @app_commands.describe(distro='Assign yourself a role')
async def distro(interaction: discord.Interaction, distro: typing.Literal[ async def distro(interaction: discord.Interaction, distro: typing.Literal[
'LFS', 'Kiss', 'Gentoo', 'Void', 'NixOS', 'Alpine', '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', 'OpenSuSE', 'Debian', 'Debian based', 'Solus', 'Fedora',
'Ubuntu', 'Ubuntu Based', 'BSD', 'MacOS', 'Windows' 'Ubuntu', 'Ubuntu Based', 'BSD', 'MacOS', 'Windows'
]): ]):
if not interaction.guild.id==config["guild"]:
print("Role assignment attempted from unknown guild.")
return
user = interaction.user user = interaction.user
if distro == 'LFS': if distro == 'LFS':
user = interaction.user user = interaction.user
@ -178,8 +182,10 @@ async def distro(interaction: discord.Interaction, distro: typing.Literal[
# This context menu command only works on messages # 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): async def report_message(interaction: discord.Interaction, message: discord.Message):
if not interaction.guild.id==config["guild"]:
return
await interaction.response.send_message( await interaction.response.send_message(
f'Thanks for reporting this message by {message.author.mention} to our moderators.', ephemeral=True 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}""" System: {sys.platform}"""
url_view = discord.ui.View() url_view = discord.ui.View()
await interaction.response.send_message(embed=embed, view=url_view) await interaction.response.send_message(embed=embed, view=url_view)
print("Status queried.")
client.run(sys.argv[1]) client.run(sys.argv[1])