Skip to content

Commit

Permalink
Update bot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wfxey authored Aug 23, 2024
1 parent 5ba90c6 commit 6767a0e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ async def check_again(self, interaction: discord.Interaction):
await interaction.response.edit_message(content=f"**Pong! {round(interaction.client.latency * 1000)}ms**", view=self)

@app_commands.command(name="ping", description="Show you the current Ping of the Bot!")
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def ping(interaction: discord.Interaction):
await interaction.response.send_message(f"**Pong! {round(interaction.client.latency * 1000)}ms**", ephemeral=True, view=PingView())

Expand All @@ -242,7 +244,7 @@ async def callback(self, interaction: discord.Interaction):
privacy_policy_button = link_button(text="Show 📩", link="https://github.com/D-I-Projects/Discord-Bot/blob/main/privacy_policy.md")
github_page_button = link_button(text="Open 📩" , link="https://github.com/D-I-Projects/Discord-Bot")
discord_join_button = link_button(text="Join 📩", link="https://discord.gg/5NDYmBVdSA")
version_button = link_button(text="Show 📩", link="https://github.com/D-I-Projects/Discord-Bot/releases/tag/v24.8.23-3")
version_button = link_button(text="Show 📩", link="https://github.com/D-I-Projects/Discord-Bot/releases/tag/v24.8.23-4")
if selected_important == "Terms of Service":
await interaction.response.send_message(f"Here you can take a look at our [Terms of Service](https://github.com/D-I-Projects/Discord-Bot/blob/main/terms_of_service.md)!", view=terms_of_service_button, ephemeral=True)
elif selected_important == "Privacy Policy":
Expand All @@ -252,7 +254,7 @@ async def callback(self, interaction: discord.Interaction):
elif selected_important == "Discord":
await interaction.response.send_message(f"**A link to our [Discord Server](https://discord.gg/5NDYmBVdSA)**!", view=discord_join_button, ephemeral=True)
elif selected_important == "Version":
await interaction.response.send_message(f"**Current version : [v24.8.23-3](https://github.com/D-I-Projects/Discord-Bot/releases/tag/v24.8.23-3)**", view=version_button ,ephemeral=True)
await interaction.response.send_message(f"**Current version : [v24.8.23-4](https://github.com/D-I-Projects/Discord-Bot/releases/tag/v24.8.23-4)**", view=version_button ,ephemeral=True)

@app_commands.command(name="important", description="Important Links for the Discord Bot.")
@app_commands.allowed_installs(guilds=True, users=True)
Expand Down Expand Up @@ -281,7 +283,29 @@ async def location_autocomplete(interaction: discord.Interaction, current: str)
for loc in locations if current.lower() in loc.lower()
]

class UpTimeView(discord.ui.View):
def __init__(self):
super().__init__()

check_again_button = discord.ui.Button(label="Check again", style=discord.ButtonStyle.success)
check_again_button.callback = self.check_again
self.add_item(check_again_button)

async def check_again(self, interaction: discord.Interaction):
current_time = datetime.datetime.now()
uptime_duration = current_time - start_time
uptime_days = uptime_duration.days
uptime_seconds = uptime_duration.seconds
hours, remainder = divmod(uptime_seconds, 3600)
minutes, seconds = divmod(remainder, 60)

uptime_message = f"Uptime: {uptime_days} days, {hours} hours, {minutes} minutes, {seconds} seconds"

await interaction.response.edit_message(content=uptime_message, view=self)

@app_commands.command(name="uptime", description="Shows the bot's uptime.")
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def uptime_command(interaction: discord.Interaction):
current_time = datetime.datetime.now()
uptime_duration = current_time - start_time
Expand All @@ -291,7 +315,8 @@ async def uptime_command(interaction: discord.Interaction):
minutes, seconds = divmod(remainder, 60)

uptime_message = f"Uptime: {uptime_days} days, {hours} hours, {minutes} minutes, {seconds} seconds"
await interaction.response.send_message(uptime_message, ephemeral=True)
await interaction.response.send_message(uptime_message, ephemeral=True, view=UpTimeView())


@app_commands.command(name="savefile", description="Saves a text file.")
@app_commands.allowed_installs(guilds=True, users=True)
Expand Down

0 comments on commit 6767a0e

Please sign in to comment.