some refractor

This commit is contained in:
2022-08-29 00:38:13 +03:00
parent caa8d6b20e
commit 4a33b35283
9 changed files with 87 additions and 89 deletions

View File

@@ -130,7 +130,7 @@ class Admin(commands.Cog, name='Admin'):
await inter.response.send_message("You don`t have permissions", ephemeral=True)
@commands.has_permissions(administrator=True)
@commands.command(
@commands.slash_command(
name="set_time",
description="Read list of tracks for user",
options=[
@@ -142,16 +142,16 @@ class Admin(commands.Cog, name='Admin'):
await inter.response.send_message(f"Change max audio duration to {seconds} sec", ephemeral=True)
@commands.has_permissions(administrator=True)
@commands.command(
@commands.slash_command(
name="set_bot_channel",
description="Set channel whitch itterate with bot",
options=[
Option("channel", "specify channel", OptionType.channel, required=True),
]
)
async def set_time(self, inter, _channel: commands.Range[5, 30]):
await write_json(inter.guild.id, "channel", _channel)
await inter.response.send_message(f"Channet setted up to{_channel} sec", ephemeral=True)
async def set_bot_channel(self, inter, channel):
await write_json(inter.guild.id, "channel", channel.id)
await inter.response.send_message(f"Channel setted up to {channel.mention}", ephemeral=True)
def setup(bot): # an extension must have a setup function

View File

@@ -1,12 +1,15 @@
import logging
import random
from os import path, makedirs, rename, remove
from typing import Optional
import disnake
from disnake import Option, OptionType
from disnake.ext import commands
from lib.Comands import determine_time
from lib.DB import read_db, check_exist_audio, add_audio
from lib.Player import play_audio
from lib.Player import play_audio, get_audio_list
# todo: write chose audio from list by slash command
@@ -54,6 +57,18 @@ class Audio(commands.Cog):
else:
logging.info(f'Skip playing by any else')
@commands.slash_command(name="play_audio",
description="Set channel whitch itterate with bot",
options=[
Option("audio", "select audio", OptionType.string, required=True),
]
)
async def play_audio(self,
integration: disnake.ApplicationCommandInteraction,
audio: Optional[str]
) -> None:
await get_audio_list(integration, audio)
@commands.command(name="upload_audio")
async def upload_audio(self, ctx, user=None):
user = user or ctx.author