-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimestamp.py
More file actions
35 lines (29 loc) · 1.27 KB
/
Copy pathtimestamp.py
File metadata and controls
35 lines (29 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from typing import Literal
import discord
from discord import app_commands
from discord.ext import commands
from datetime import datetime as dt
from dateutil import tz
class timestamp(commands.Cog):
def __init__(cmd, bot: commands.Bot) -> None:
cmd.bot = bot
@app_commands.command(name="timestamp", description="Create a timestamp")
@app_commands.allowed_installs(guilds=False, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def about(
cmd,
interaction: discord.Interaction,
hr: int,
min: int,
sec: int,
day: int = 0,
month: int = 0,
year: int = 0,
type: Literal["t", "T", "d", "D", "f", "F", "R"] = "R"):
day = day if day != 0 else dt.now(tz=tz.gettz('Europe/Berlin')).day
month = month if month != 0 else dt.now(tz=tz.gettz('Europe/Berlin')).month
year = year if year != 0 else dt.now(tz=tz.gettz('Europe/Berlin')).year
timestamp = dt(year, month, day, hr, min, sec, tzinfo=tz.gettz('Europe/Berlin'))
await interaction.response.send_message(f"```<t:{round(timestamp.timestamp())}:{type}>```", ephemeral=True)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(timestamp(bot))