Make things actually work
+ minor improvement of ststus command though that will be revised soon anywaypull/2/head
parent
c48b45d9bf
commit
0aade0c6fd
13
bot.py
13
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])
|
||||
|
|
Loading…
Reference in New Issue