from time import time import discord, asyncio import os from discord.ext import commands from discord import app_commands import database.controller intents = discord.Intents.default() intents.members = True intents.dm_messages = True app = commands.Bot(command_prefix=",", intents=intents) app.db = database.controller.Database("database.db") # load cogs async def load_cogs(): for filename in os.listdir("bot/commands"): if filename.endswith(".py"): await app.load_extension(f"bot.commands.{filename[:-3]}") async def time_to_bereal(): # Get subscribers t = int(time()) subscribers = app.db.get_subscribers() # Send message to all subscribers for subscriber in subscribers: user = await app.fetch_user(subscriber.user_id) await user.send(f"# :warning: It's time to BeReal.\nOpen BeReal. to post what you are doing right now.\n") app.time_to_bereal = time_to_bereal @app.event async def on_ready(): print("Running") await load_cogs() await app.tree.sync()