diff options
| author | salmonik <raisersoft@proton.me> | 2026-01-15 14:37:22 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-01-15 14:37:22 +0100 |
| commit | edff41f3468996dad5e66d34ac8ab1f5a238751f (patch) | |
| tree | 33a567cd202fedf010764c3e4b8cae8827851f7f /cogs/music/play.py | |
| parent | asyncio issues when starting (diff) | |
| download | senator-sperma-edff41f3468996dad5e66d34ac8ab1f5a238751f.tar.gz senator-sperma-edff41f3468996dad5e66d34ac8ab1f5a238751f.zip | |
minor improvements
Diffstat (limited to 'cogs/music/play.py')
| -rw-r--r-- | cogs/music/play.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cogs/music/play.py b/cogs/music/play.py index 2c5b641..d77d772 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import discord | 2 | import discord |
| 3 | import mutagen | 3 | import mutagen |
| 4 | from typing import List, Tuple, Optional, Callable, Awaitable, Union | 4 | from typing import List, Tuple, Callable, Awaitable |
| 5 | from os import PathLike | ||
| 5 | 6 | ||
| 6 | from . import play_utils | 7 | from cogs.music import play_utils |
| 7 | from discord.ext import commands | 8 | from discord.ext import commands |
| 8 | from discord.commands import Option, OptionChoice | 9 | from discord.commands import OptionChoice |
| 9 | import logging | 10 | import logging |
| 10 | 11 | ||
| 11 | logger = logging.getLogger(__name__) | 12 | logger = logging.getLogger(__name__) |
| @@ -16,7 +17,8 @@ class Play(commands.Cog): | |||
| 16 | self.temp_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "temp") | 17 | self.temp_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "temp") |
| 17 | self.path_mapping = {} # Maps display names to full paths | 18 | self.path_mapping = {} # Maps display names to full paths |
| 18 | 19 | ||
| 19 | async def _create_search_embed(self, candidates: List[str]) -> Tuple[discord.Embed, discord.ui.View]: | 20 | @staticmethod |
| 21 | async def _create_search_embed(candidates: List[str]) -> Tuple[discord.Embed, discord.ui.View]: | ||
| 20 | """Create an embed and view for search results.""" | 22 | """Create an embed and view for search results.""" |
| 21 | embed = discord.Embed( | 23 | embed = discord.Embed( |
| 22 | title="Wyniki wyszukiwania", | 24 | title="Wyniki wyszukiwania", |
| @@ -204,7 +206,7 @@ class Play(commands.Cog): | |||
| 204 | @discord.slash_command(name="grajcuj_plik", description="grajcuj plik") | 206 | @discord.slash_command(name="grajcuj_plik", description="grajcuj plik") |
| 205 | async def play_file(self, ctx: discord.ApplicationContext, attachment: discord.Attachment = discord.Option(discord.Attachment, "co zagrać??", required=True)): | 207 | async def play_file(self, ctx: discord.ApplicationContext, attachment: discord.Attachment = discord.Option(discord.Attachment, "co zagrać??", required=True)): |
| 206 | await ctx.defer() | 208 | await ctx.defer() |
| 207 | file_path = os.path.join(self.temp_dir, attachment.filename) | 209 | file_path: PathLike[str] | str = os.path.join(self.temp_dir, attachment.filename) |
| 208 | await attachment.save(file_path) | 210 | await attachment.save(file_path) |
| 209 | await play_utils.PlayUtils(self.bot).play(ctx, file_path) | 211 | await play_utils.PlayUtils(self.bot).play(ctx, file_path) |
| 210 | 212 | ||
