modified: bot.py
This commit is contained in:
24
bot.py
24
bot.py
@@ -338,10 +338,10 @@ class Giveaway:
|
||||
|
||||
@client.hybrid_command()
|
||||
async def startgiveaway(ctx, platform: str, prize: str, num_winners: int, title: str, subtitle: str, duration: str):
|
||||
"""Erstellt ein Giveaway. Nur für Mods und höher verfügbar."""
|
||||
"""Creates a giveaway. Only available for mods and higher."""
|
||||
user_data = load_user_data(ctx.author.id)
|
||||
if user_data["permission"] < 5:
|
||||
await ctx.send("Du hast keine Berechtigung, um ein Giveaway zu erstellen.")
|
||||
await ctx.send("You do not have permission to create a giveaway.")
|
||||
return
|
||||
|
||||
if duration.endswith("m"):
|
||||
@@ -351,7 +351,7 @@ async def startgiveaway(ctx, platform: str, prize: str, num_winners: int, title:
|
||||
days = int(duration[:-1])
|
||||
end_time = datetime.now() + timedelta(days=days)
|
||||
else:
|
||||
await ctx.send("Ungültige Dauer. Bitte benutze 'm' für Minuten oder 'd' für Tage.")
|
||||
await ctx.send("Invalid duration. Please use 'm' for minutes or 'd' for days.")
|
||||
return
|
||||
|
||||
# Neues Giveaway erstellen
|
||||
@@ -359,13 +359,13 @@ async def startgiveaway(ctx, platform: str, prize: str, num_winners: int, title:
|
||||
giveaway_id = len(giveaways) + 1
|
||||
giveaways[giveaway_id] = giveaway
|
||||
|
||||
button = Button(label="Teilnehmen", style=discord.ButtonStyle.green, custom_id=f"giveaway_{giveaway_id}")
|
||||
button = Button(label="Participate", style=discord.ButtonStyle.green, custom_id=f"giveaway_{giveaway_id}")
|
||||
view = View()
|
||||
view.add_item(button)
|
||||
|
||||
embed = discord.Embed(
|
||||
title=title,
|
||||
description=f"{subtitle}\n\nPreis: {prize}\nPlattform: {platform}\nAnzahl der Gewinner: {num_winners}\nEndet in: {duration}",
|
||||
description=f"{subtitle}\n\nPrize: {prize}\nPlatform: {platform}\nNumber of winners: {num_winners}\nEnds in: {duration}",
|
||||
color=0x00ff00
|
||||
)
|
||||
embed.set_footer(text=f"Giveaway endet am {end_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
@@ -375,7 +375,7 @@ async def startgiveaway(ctx, platform: str, prize: str, num_winners: int, title:
|
||||
|
||||
@tasks.loop(minutes=1)
|
||||
async def check_giveaway(giveaway_id):
|
||||
"""Überprüft alle 1 Minute, ob das Giveaway beendet ist."""
|
||||
"""Checks every 1 minute to see if the giveaway has ended."""
|
||||
giveaway = giveaways.get(giveaway_id)
|
||||
|
||||
if giveaway and giveaway.is_finished():
|
||||
@@ -384,7 +384,7 @@ async def check_giveaway(giveaway_id):
|
||||
winners = giveaway.pick_winners()
|
||||
if winners:
|
||||
winner_mentions = ", ".join([winner.mention for winner in winners])
|
||||
await giveaway.ctx.send(f"🎉 Glückwunsch an die Gewinner des Giveaways '{giveaway.title}'! Die Gewinner sind: {winner_mentions}")
|
||||
await giveaway.ctx.send(f"🎉 Congratulations to the winners of the giveaway '{giveaway.title}'! The winners are: {winner_mentions}")
|
||||
|
||||
# Jeden Gewinner benachrichtigen und zur Webseite schicken
|
||||
for winner in winners:
|
||||
@@ -394,13 +394,13 @@ async def check_giveaway(giveaway_id):
|
||||
await winner.send(f"🎁 Congratulations! You won the giveaway '{giveaway.title}'!\n"
|
||||
f"Please claim your prize using the following link: {GIVEAWAY_WEBSITE_URL}{giveaway.prize_uuid}")
|
||||
else:
|
||||
await giveaway.ctx.send(f"Das Giveaway '{giveaway.title}' wurde beendet, aber es gab keine Teilnehmer.")
|
||||
await giveaway.ctx.send(f"The giveaway '{giveaway.title}' has ended, but there were no participants.")
|
||||
|
||||
del giveaways[giveaway_id]
|
||||
|
||||
@client.event
|
||||
async def on_interaction(interaction):
|
||||
"""Bearbeitet die Teilnahme an einem Giveaway."""
|
||||
"""Processes participation in a giveaway."""
|
||||
# Überprüfen, ob es sich um eine Button-Interaktion handelt und ein custom_id vorhanden ist
|
||||
if interaction.type == discord.InteractionType.component and "custom_id" in interaction.data:
|
||||
if interaction.data["custom_id"].startswith("giveaway_"):
|
||||
@@ -409,13 +409,13 @@ async def on_interaction(interaction):
|
||||
|
||||
if giveaway:
|
||||
if giveaway.is_finished():
|
||||
await interaction.response.send_message("Dieses Giveaway ist bereits beendet.", ephemeral=True)
|
||||
await interaction.response.send_message("This giveaway has already ended.", ephemeral=True)
|
||||
else:
|
||||
added = giveaway.add_participant(interaction.user)
|
||||
if added:
|
||||
await interaction.response.send_message("Du hast erfolgreich am Giveaway teilgenommen!", ephemeral=True)
|
||||
await interaction.response.send_message("You have successfully entered the giveaway!", ephemeral=True)
|
||||
else:
|
||||
await interaction.response.send_message("Du nimmst bereits am Giveaway teil.", ephemeral=True)
|
||||
await interaction.response.send_message("You're already participating in this giveaway.", ephemeral=True)
|
||||
else:
|
||||
# Logge Interaktionen, die nicht den erwarteten Typ haben
|
||||
logger.error(f"Unbekannte Interaktion: {interaction.type}, Daten: {interaction.data}")
|
||||
|
||||
Reference in New Issue
Block a user