some code changes
This commit is contained in:
42
bot.py
Normal file → Executable file
42
bot.py
Normal file → Executable file
@@ -1,18 +1,17 @@
|
||||
#!/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
|
||||
from lib import work_with_cogs
|
||||
from lib import preload_checks, determine_prefix
|
||||
from lib import logger
|
||||
|
||||
preload_checks()
|
||||
|
||||
load_dotenv()
|
||||
check_conf()
|
||||
|
||||
intents = disnake.Intents(messages=True,
|
||||
guilds=True,
|
||||
@@ -27,21 +26,19 @@ bot = commands.Bot(command_prefix=determine_prefix,
|
||||
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}')
|
||||
slash_commands = '\n\t* '.join(f'{r.name}: {r.description}' for r in bot.slash_commands)
|
||||
_commands = '\n\t* '.join(f'{r.name}: {r.description}' for r in bot.commands)
|
||||
logger.info(f'Bot started')
|
||||
logger.info('We have logged in as {0.user}'.format(bot))
|
||||
logger.info('Version of bot is - v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
|
||||
logger.info(f'list of all slash commands: \n\t* {slash_commands}')
|
||||
logger.info(f'list of all commands: \n\t* {_commands}')
|
||||
|
||||
|
||||
@bot.slash_command(
|
||||
@@ -61,13 +58,16 @@ async def on_ready():
|
||||
)
|
||||
]
|
||||
)
|
||||
@commands.is_owner()
|
||||
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)
|
||||
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)
|
||||
|
||||
@slash_cogs.error
|
||||
async def cogs_error(inter, what_do):
|
||||
await inter.response.send_message(f'{what_do}', ephemeral=True)
|
||||
logger.error(f'User {inter.author} tries to use cogs func')
|
||||
|
||||
|
||||
bot.run(os.getenv('TOKEN'))
|
||||
|
||||
Reference in New Issue
Block a user