fixed start after move

This commit is contained in:
bacon
2024-03-18 02:08:16 +03:00
parent fff1a5c0c7
commit 76d1625346
3 changed files with 53 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import random
import disnake
from disnake import OptionChoice, Option, OptionType, Member, VoiceState
from disnake import OptionChoice, Option, OptionType, Member, VoiceState, ApplicationCommandInteraction
from disnake.ext import commands
from integral_lib.ListGenerator import ListGenerator
@@ -59,7 +59,17 @@ class Audio(commands.Cog, name='Audio'):
await inter.response.send_message('You`re not in voice', ephemeral=True)
@playaudio.autocomplete('audio')
async def list_to_play(self, inter: disnake.ApplicationCommandInteraction, current: str):
async def list_to_play(self, inter: ApplicationCommandInteraction, current: str):
"""
Asynchronously generates a list of OptionChoices for the given audio files based on the user input.
Parameters:
- inter: disnake.ApplicationCommandInteraction - The interaction context for the command.
- current: str - The current user input to filter the audio file choices.
Returns:
- list[OptionChoice] - A list of OptionChoice objects representing the available audio file choices.
:param current:
:param inter: ApplicationCommandInteraction
"""
current = current.lower()
_dict: dict = {}
for f in ListGenerator('audio'):

View File

@@ -15,6 +15,15 @@ from .Logger import logger
def cog_list(fold: str = './cogs') -> List[str]:
"""
A function that generates a list of cog names based on the files present in a specified folder.
Parameters:
- fold (str): The directory path where the cog files are located. Defaults to './cogs'.
Returns:
- List[str]: A list of cog names without the '.py' extension.
"""
cogs_list = []
for _filename in listdir(fold):
if _filename.endswith('.py'):
@@ -25,6 +34,22 @@ def cog_list(fold: str = './cogs') -> List[str]:
def work_with_cogs(what_do: str,
bot: InteractionBotBase,
cog: str | list):
"""
Perform the specified action on the given cog or list of cogs.
Args:
what_do (str): The action to perform (load, unload, reload, disable, enable).
bot (InteractionBotBase): The bot instance to work with.
cog (str | list): The name of the cog or a list of cogs to work with.
Raises:
ValueError: If the action is not recognized.
Returns:
None
--------
:param cog: str | list
:param bot: InteractionBotBase
:param what_do: str = ['load', 'unload', 'reload', 'disable', 'enable']
"""
if isinstance(cog, str):
cog = cog.split()
for _filename in cog:
@@ -49,3 +74,5 @@ def work_with_cogs(what_do: str,
f'cogs/{_filename}.py')
bot.load_extension(f'cogs.{_filename}')
logger.info(f'Cog {_filename} started and enabled')
else:
raise ValueError(f"Unrecognized action: {what_do}")

View File

@@ -37,6 +37,18 @@ async def read_json(guild: int, _param: str):
async def write_json(guild: int, param_name: str, param: str or int):
"""
A function to write JSON data to a file after updating or adding a parameter value.
Parameters:
- guild: an integer representing the guild ID
- param_name: a string representing the parameter name
- param: a string or integer representing the parameter value
Returns:
This function does not return anything.
"""
with open(getenv('CONF_FILE'), encoding='utf-8') as f:
try:
_json = load(f)
@@ -54,7 +66,8 @@ async def write_json(guild: int, param_name: str, param: str or int):
def determine_prefix(bot: commands.Bot, msg):
"""
Determite per-server bot prefix
Determine the per-server bot prefix based on the given message object.
:param bot: Disnake Bot object
:param msg: Disnake msg object
:return: prefix for server, default is $