So, i want to do an Timestamp to my Giveaway Command for when the Giveaway Ends. Now the Timestamp is 01.01.1970, i imported datetime and did an convert system. There isnt any Error, so it must been my Code. Any ideas how i can do that? I have no clue how i can change that
def convert(time):
pos = ["s", "m", "h", "d"]
time_dict = {"s": 1, "m": 60, "h": 3600, "d": 3600 * 24}
unit = time[-1]
if unit not in pos:
return -1
try:
val = int(time[:-1])
except:
return -2
return val * time_dict[unit]
My Convert System
@client.command()
@commands.has_permissions(administrator=True)
async def gewinnspiel(ctx):
await ctx.send(
"**Beginnen wir mit diesem Gewinnspiel! Beantworten diese Fragen innerhalb von 15 Sekunden!**"
)
questions = [
"In welchem Kanal soll es gehostet werden?",
"Wie lange soll das Giveaway dauern? (s|m|h|d)",
"Was ist der Preis des Giveaways?"
]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('message', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send(
'**Du hast nicht in zeit geantwortet! Bitte sei schneller.**')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(
f"**Du hast den Kanal nicht richtig Makiert. Versuche es so: {ctx.channel.mention} nächstes mal.**"
)
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(
f"**Du hast die Zeit nicht mit einer richtigen Einheit beantwortet. Benutze beim nächsten Mal (s|m|h|d)!**"
)
return
elif time == -2:
await ctx.send(
f"**Die Zeit muss eine ganze Zahl sein. Bitte geb beim nächsten Mal eine ganze Zahl ein.**"
)
return
prize = answers[2]
await ctx.send(
f"Das Gewinnspiel wird in {channel.mention} sein und dauert {answers[1]}!"
)
timestamp = time
embed = nextcord.Embed(
title="Gewinnspiel!",
description=
f"Reagiere mit :tada: um teilzunehmen!\nPreis: {prize}\n Dauer: {answers[1]}\nHosted von: {ctx.author.mention}",timestamp=(datetime.datetime.utcfromtimestamp(timestamp)),
color=ctx.author.color)
my_msg = await channel.send(embed=embed)
await my_msg.add_reaction('🎉')
await asyncio.sleep(time)
new_msg = await channel.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
await channel.send(
f"**Herzlichen Glückwunsch!**\n {winner.mention} hat {prize} Gewonnen!"
)
And this is my Code for the Giveaway
I fixed it thank to @Tim Roberts Comment, First i imported time then i renamed my Time Variable to Timer and changed the Timestamp = Value
import Time
...
timestamp = time.time() + Timer