v0.0.6\nplay_audio fixes
This commit is contained in:
173
bot.py
173
bot.py
@@ -1,90 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
import disnake
|
||||
from disnake import OptionChoice, OptionType, Option
|
||||
from disnake.ext import commands
|
||||
from __init__ import version_info as ver
|
||||
from lib import work_with_cogs, cog_list
|
||||
from lib import preload_checks, determine_prefix
|
||||
from lib import logger
|
||||
|
||||
preload_checks()
|
||||
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
asyncio.run(work_with_cogs('load', bot, asyncio.run(cog_list())))
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
logger.info(f'Bot started')
|
||||
logger.info('We have logged in as {0.user}'.format(bot))
|
||||
logger.info(f'Version of bot is - v{ver.major}.{ver.minor}.{ver.micro}-{ver.releaselevel}')
|
||||
|
||||
|
||||
@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"),
|
||||
OptionChoice("enable", "enable"),
|
||||
OptionChoice("disable", "disable"),
|
||||
]
|
||||
),
|
||||
Option(
|
||||
'cog',
|
||||
description="specify cog",
|
||||
type=OptionType.string
|
||||
)
|
||||
]
|
||||
)
|
||||
@commands.is_owner()
|
||||
async def slash_cogs(inter, what_do, cog: str = asyncio.run(cog_list())) -> None:
|
||||
await work_with_cogs(what_do, bot, cog)
|
||||
await inter.response.send_message(f'Cog {cog} is {what_do}ed', ephemeral=True)
|
||||
|
||||
|
||||
@slash_cogs.autocomplete('cog')
|
||||
async def _cog_opt(inter: disnake.ApplicationCommandInteraction, current: str, what_do) -> List[OptionChoice]:
|
||||
_what = ['load', 'reload', 'unload', 'disable']
|
||||
if what_do in _what:
|
||||
_list = await cog_list()
|
||||
elif what_do == 'enable':
|
||||
_list = await cog_list('./cogs/disabled/')
|
||||
return [
|
||||
OptionChoice(name=choice, value=choice)
|
||||
for choice in _list if current.lower() in choice.lower()
|
||||
]
|
||||
|
||||
|
||||
@slash_cogs.error
|
||||
async def cogs_error(inter, what_do):
|
||||
await inter.response.send_message(f'Error', ephemeral=True)
|
||||
logger.error(f'User {inter.author} tries to use cogs func\n{what_do}\n')
|
||||
|
||||
|
||||
bot.run(os.getenv('TOKEN'))
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
import disnake
|
||||
from disnake import OptionChoice, OptionType, Option
|
||||
from disnake.ext import commands
|
||||
from __init__ import version_info as ver
|
||||
from lib import work_with_cogs, cog_list
|
||||
from lib import preload_checks, determine_prefix
|
||||
from lib import logger
|
||||
|
||||
preload_checks()
|
||||
|
||||
|
||||
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,
|
||||
|
||||
)
|
||||
|
||||
|
||||
asyncio.run(work_with_cogs('load', bot, asyncio.run(cog_list())))
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
logger.info(f'Bot started')
|
||||
logger.info(f'Disnake version {disnake.__version__}')
|
||||
logger.info('We have logged in as {0.user}'.format(bot))
|
||||
logger.info(f'Version of bot is - v{ver.major}.{ver.minor}.{ver.micro}-{ver.releaselevel}')
|
||||
|
||||
|
||||
@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=["load", "unload", "reload", "enable", "disable"]
|
||||
),
|
||||
Option(
|
||||
'cog',
|
||||
description="specify cog",
|
||||
type=OptionType.string
|
||||
)
|
||||
]
|
||||
)
|
||||
@commands.is_owner()
|
||||
async def slash_cogs(inter: disnake.ApplicationCommandInteraction, what_do, cog: str):
|
||||
await work_with_cogs(what_do, bot, cog)
|
||||
await inter.response.send_message(f'Cog {cog} is {what_do}ed', ephemeral=True)
|
||||
|
||||
|
||||
@slash_cogs.autocomplete('cog')
|
||||
async def _cog_opt(inter: disnake.ApplicationCommandInteraction, current: str, what_do):
|
||||
current = current.lower()
|
||||
if what_do == 'enable':
|
||||
_list = await cog_list('./cogs/disabled/')
|
||||
else:
|
||||
_list = await cog_list()
|
||||
return [choice for choice in _list if current in choice.lower()]
|
||||
|
||||
|
||||
@slash_cogs.error
|
||||
async def cogs_error(inter, what_do):
|
||||
await inter.response.send_message(f'Error', ephemeral=True)
|
||||
logger.error(f'User {inter.author} tries to use cogs func\n{what_do}\n')
|
||||
|
||||
|
||||
bot.run(os.getenv('TOKEN'))
|
||||
|
||||
Reference in New Issue
Block a user