-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
|
||
from datetime import datetime | ||
from typing import TYPE_CHECKING | ||
|
||
import discord | ||
from discord import app_commands | ||
from discord.ext import commands | ||
|
||
if TYPE_CHECKING: | ||
from __main__ import DiscordBot | ||
|
||
|
||
class BaduraCog(commands.Cog): | ||
""" | ||
Class for commands related with Badura | ||
""" | ||
|
||
def __init__(self, bot: DiscordBot) -> None: | ||
super().__init__() | ||
self.bot: DiscordBot = bot | ||
|
||
@app_commands.command(name="wypomnienie") | ||
async def update_rebuke(self, interaction: discord.Interaction) -> None: | ||
""" | ||
Update wypomnienie | ||
""" | ||
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||
with open("./soundboards/wypomnienie.txt", "w+") as file: | ||
file.write(timestamp) | ||
await interaction.response.send_message("Wypomnienie zostało zaktualizowane.") | ||
|
||
@app_commands.command(name="kiedy_wypomnienie") | ||
async def get_last_rebuke(self, interaction: discord.Interaction) -> None: | ||
""" | ||
Command to get last wypomnienie | ||
""" | ||
with open("./soundboards/wypomnienie.txt", "r") as file: | ||
last_rebuke = file.read() | ||
last_rebuke_time = datetime.strptime(last_rebuke, "%Y-%m-%d %H:%M:%S") | ||
time_difference = datetime.now() - last_rebuke_time | ||
await interaction.response.send_message( | ||
f"""Ostatnie wypomnienie było {time_difference.days} dni, {time_difference.seconds // 3600} | ||
godzin i {time_difference.seconds % 3600 // 60} minut temu.""" | ||
) |