geas-bot/app/cogs/events/on_ready.py
Vivek Santayana 1fa5029212 Changed file structure.
Moved code to main bot and cog files.
2021-07-15 23:13:01 +01:00

30 lines
1.0 KiB
Python

import os # OS Locations
import yaml # YAML parser for Bot config files
import asyncio # Discord Py Dependency
import discord # Main Lib
from discord.ext import commands # Commands module
from discord_slash import SlashCommand, SlashContext, cog_ext, utils # Slash Command Library
from discord_slash.utils.manage_commands import create_choice, create_option # Slash Command features
import logging
# logger and handler
from bot import clearConfig, configFile, setConfig, yaml_dump, yaml_load
#### Actions for the Bot to take once it is ready to interact with commands.
class on_ready(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
#### Create any missing config entries for guilds
for guild in self.client.guilds:
setConfig(guild)
#### Delete any extra config entries for guilds the bot is not in
conf = yaml_load(configFile)
for key in list(conf):
clearConfig(key)
def setup(client):
client.add_cog(on_ready(client))