Untitled

mail@pastecode.io avatar
unknown
python
5 months ago
1.9 kB
1
Indexable
status = server_var('contest_status')
weekly_theme = server_var('contest_theme')
contest_time = int(server_var('contest_time'))
member = "**révélé à la fin du weekly**"

if status != "post":
    set_error("❌ Votes are already in progress!")

if fuzz.ratio(theme.lower(), weekly_theme.lower()) >= 60:
    set_error("❌ Ton thème ne doit pas être celui en cours!")

db = SlashMongo("Weekly")
cont = await db.find_one({"uid_db": int(user.id)}) or {}

msg_id = cont.get("msgid_db", "")
edit_count = cont.get("edit_count_db", -1)
wins = cont.get("wins_db", 0)

if edit_count >= 2:
    set_error("❌ Tu as atteint la limite de 2 éditions!")

await db.update_one(
    {"uid_db": int(user.id)},
    {
        "$set": {
            "theme_db": theme,
            "vote_db": 0,
            "voter_db": [user.id],
            "edit_count_db": edit_count + 1,
            "wins_db": wins
        }
    },
    upsert=True
)

if contest_time == 0:
    await schedule_clock(
        custom_id="weekly_votes",
        time=get_time("after 5760 minutes"),
        metadata={}
    )
    await schedule_clock(
        custom_id="weekly_winner",
        time=get_time("after 10080 minutes"),
        metadata={}
    )
    update_server_var('contest_time', int(unix_timestamp))

timer = int(server_var('contest_time')) + 345572
vote = f"disponible <t:{timer}:R>"

b = ComponentBuilder()
b.add_button("Vote", "success", custom_id="like", emoji="🩷")
b.add_button("Infos", "secondary", custom_id="informations", emoji="ℹ️")
set_components(b)

add_attachment(media)
set_response_channel(1015259830824472719)
set_response_message("Média posté 🩷")


new_url = response.attachments[0].url

await db.update_one(
    {"uid_db": int(user.id)},
    {"$set": {"msgid_db": response.id, "img_db": new_url}},
    upsert=True
)

if msg_id:
    delete_message(1015259830824472719, msg_id)
    
add_roles(user, 1029005768990670868)
Leave a Comment