some refractor
This commit is contained in:
73
bot.py
Normal file
73
bot.py
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import disnake
|
||||
from disnake import OptionChoice, OptionType, Option
|
||||
from disnake.ext import commands
|
||||
from dotenv import load_dotenv
|
||||
from __init__ import version_info
|
||||
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():
|
||||
slash_commands = [r.name for r in bot.slash_commands]
|
||||
commands = [r.name for r in bot.commands]
|
||||
logging.info(f'Bot started')
|
||||
logging.info('We have logged in as {0.user}'.format(bot))
|
||||
logging.info('Version of bot is - v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
|
||||
logging.info(f'list of all slash commmmands: \n{slash_commands}')
|
||||
logging.info(f'list of all commmmands: \n{commands}')
|
||||
|
||||
|
||||
@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'))
|
||||
Reference in New Issue
Block a user