From a344db3ad1bcc64baff9d9e338c2fe53bd8e7c63 Mon Sep 17 00:00:00 2001 From: Aaron Riedel Date: Fri, 12 Jul 2024 14:20:28 +0200 Subject: [PATCH] add survey bot --- survey.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 survey.py diff --git a/survey.py b/survey.py new file mode 100644 index 0000000..8812b88 --- /dev/null +++ b/survey.py @@ -0,0 +1,42 @@ +import discord +import asyncio +import time +import datetime +import random +import os +from os import system +from os import environ +from discord.ext import commands +from discord.commands import Option +from discord.commands import permissions +from discord.ui import InputText, Modal + +def left(s, amount): + return s[:amount] + +def right(s, amount): + return s[-amount:] + +def mid(s, offset, amount): + return s[offset:offset+amount] + +token = os.environ['TOKEN'] +survey_channel = os.environ['SURVEY_CHANNEL'] +mention_id = os.environ['MENTION_ID'] +guild_id = os.environ['GUILD_ID'] +runtime = 48 + +bot = discord.Bot(description=None) + +@bot.event +async def on_ready(): + print("Bot ready on Version %s..." % discord.__version__) + # build survey + po = discord.Poll(question="Wie habt ihr nächste Woche Zeit?", answers=[discord.PollAnswer(text="Montag", emoji="1\u20E3"), discord.PollAnswer(text="Dienstag", emoji="2\u20E3"), discord.PollAnswer(text="Mittwoch", emoji="3\u20E3"), discord.PollAnswer(text="Donnerstag", emoji="4\u20E3"), discord.PollAnswer(text="Freitag", emoji="5\u20E3"), discord.PollAnswer(text="Samstag", emoji="6\u20E3"), discord.PollAnswer(text="Sonntag", emoji="7\u20E3"), discord.PollAnswer(text="keine Zeit", emoji="❌")], duration=runtime, allow_multiselect=True) + # send message + msg = await bot.get_channel(survey_channel).send(content="||%s||"% bot.get_guild(guild_id).get_role(mention_id).mention ,poll=po) + await msg.create_thread(name="Diskussion") + # close connection + await bot.close() + +bot.run(token) \ No newline at end of file