diff --git a/text_commands_cog.py b/text_commands_cog.py index 9167eb58dc59406835c68545003a9177c0b62002..d6f8051bcd563d7c00e4399b53f6d51f15a72e04 100644 --- a/text_commands_cog.py +++ b/text_commands_cog.py @@ -3,10 +3,12 @@ import os import random import discord -from discord.ext import commands +from discord.ext import commands, tasks import utils +motivation_channels = [566329830682132502, 666937772879249409, 693194667075960875] + class TextCommandsCog(commands.Cog): def __init__(self, bot): @@ -14,6 +16,7 @@ class TextCommandsCog(commands.Cog): self.text_commands = {} self.cmd_file = os.getenv("DISCORD_TEXT_COMMANDS_FILE") self.load_text_commands() + self.motivation_loop.start() def load_text_commands(self): """ Loads all appointments from APPOINTMENTS_FILE """ @@ -153,3 +156,13 @@ class TextCommandsCog(commands.Cog): message = await channel.fetch_message(payload.message_id) if len(message.embeds) > 0 and message.embeds[0].title == "Neuer Motivations Text": await self.motivation_approved(message) + + @tasks.loop(hours=1 + (random.random() * 24)) + async def motivation_loop(self): + channel_id = random.choice(motivation_channels) + channel = await self.bot.fetch_channel(channel_id) + texts = self.text_commands.get("!motivation") + + await channel.send(random.choice(texts)) + + self.motivation_loop.change_interval(hours=1 + (random.random() * 12))