import asyncio import logging import os import sys import pisya_bot import disnake from disnake import OptionChoice, OptionType, Option from disnake.ext import commands from dotenv import load_dotenv from lib.CogsPrepare import work_with_cogs from lib.Comands import determine_prefix, check_conf load_dotenv() check_conf() intents = disnake.Intents(messages=True, guilds=True, message_content=True, voice_states=True, members=True, presences=True ) bot = commands.Bot(command_prefix=determine_prefix, intents=intents, reload=True ) logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO', format='%(asctime)s - %(levelname)s - %(module)s - %(message)s') asyncio.run(work_with_cogs('load', bot)) @bot.event async def on_ready(): logging.info(f'Bot started') logging.info('We have logged in as {0.user}'.format(bot)) logging.info(f'{pisya_bot.__version__}') @bot.slash_command( name="cog", description="Work with cogs", options=[ Option( "what_do", description="Specify what do with cogs", type=OptionType.string, required=True, choices=[ OptionChoice("load", "load"), OptionChoice("unload", "unload"), OptionChoice("reload", "reload") ] ) ] ) async def slash_cogs(inter, what_do): if inter.author.id == bot.owner_id: await work_with_cogs(what_do, bot) await inter.response.send_message(f'Cogs are {what_do}ed', ephemeral=True) else: await inter.response.send_message('You`re not bot owner', ephemeral=True) bot.run(os.getenv('TOKEN'))