-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
43 lines (32 loc) · 1.32 KB
/
Copy pathbot.py
File metadata and controls
43 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio
import discord
from discord.ext import commands
from config import COMMAND_PREFIX, DISCORD_TOKEN, GUILD_ID
from supabase_setup import supabase
from services.scheduled_plan import MealPlanner
class MealManBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default() #sets the intents of the bot to default
intents.message_content = True
intents.guilds = True
intents.message_content = True
intents.members = True
super().__init__(command_prefix=COMMAND_PREFIX, intents=intents) #inherits from the Bot class, and adds those two parameters.
async def setup_hook(self):
"""Load commands and sync cogs on startup"""
await self.load_extension('cogs.ping')
await self.load_extension('cogs.register')
await self.load_extension('cogs.recipe')
await self.tree.sync(guild=discord.Object(id=GUILD_ID))
await self.tree.sync()
self.loop.create_task(self.meal_planner_background())
async def meal_planner_background(self):
await self.wait_until_ready()
planner = MealPlanner(bot=self)
await planner.run_meal_plan_for_all_groups()
async def main():
bot = MealManBot()
async with bot:
await bot.start(DISCORD_TOKEN)
if __name__ == '__main__':
asyncio.run(main())