Skip to content
Snippets Groups Projects
Commit e7c8df45 authored by dnns01's avatar dnns01
Browse files

fix $11e - add random motivation texts at random channels (from a certain list...

fix $11e - add random motivation texts at random channels (from a certain list of channels). Random texts can appear every 1 to 24 hours
parent 62d2e06b
No related branches found
No related tags found
No related merge requests found
......@@ -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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment