shbot/survey.py

42 lines
1.2 KiB
Python
Raw Normal View History

2024-07-12 14:20:28 +02:00
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']
2024-07-12 14:37:49 +02:00
survey_channel = int(os.environ['SURVEY_CHANNEL'])
mention_id = int(os.environ['MENTION_ID'])
guild_id = int(os.environ['GUILD_ID'])
2024-07-12 14:20:28 +02:00
runtime = 48
bot = discord.Bot(description=None)
@bot.event
async def on_ready():
print("Bot ready on Version %s..." % discord.__version__)
# build survey
2024-12-03 21:47:16 +01:00
po = discord.Poll(question="Habt ihr nächsten Dienstag Zeit?", answers=[discord.PollAnswer(text="Ja", emoji=""), discord.PollAnswer(text="keine Zeit", emoji="")], duration=runtime, allow_multiselect=False)
2024-07-12 14:20:28 +02:00
# send message
msg = await bot.get_channel(survey_channel).send(content="||%s||"% bot.get_guild(guild_id).get_role(mention_id).mention ,poll=po)
2024-12-03 21:47:16 +01:00
# await msg.create_thread(name="Diskussion")
2024-07-12 14:20:28 +02:00
# close connection
await bot.close()
bot.run(token)