diff options
| author | salmonik <raisersoft@proton.me> | 2025-10-01 17:44:28 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2025-10-01 17:44:28 +0200 |
| commit | 2506f2dea0ead70f7bfd37aec68f8c5ca46c98f0 (patch) | |
| tree | 9480c7221ee610691a3cc1a0ae1a04f6a8304cc0 /cogs | |
| parent | try except statement for vclogs (diff) | |
| download | senator-sperma-2506f2dea0ead70f7bfd37aec68f8c5ca46c98f0.tar.gz senator-sperma-2506f2dea0ead70f7bfd37aec68f8c5ca46c98f0.zip | |
added playing from file
Diffstat (limited to '')
| -rw-r--r-- | cogs/music/play.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cogs/music/play.py b/cogs/music/play.py index be21702..74b9e4f 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py | |||
| @@ -12,6 +12,7 @@ logger = logging.getLogger(__name__) | |||
| 12 | class Play(commands.Cog): | 12 | class Play(commands.Cog): |
| 13 | def __init__(self, bot): | 13 | def __init__(self, bot): |
| 14 | self.bot = bot | 14 | self.bot = bot |
| 15 | self.temp_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "temp") | ||
| 15 | 16 | ||
| 16 | @discord.slash_command(name="grajcuj", description="grajcujmy wszyscy!") | 17 | @discord.slash_command(name="grajcuj", description="grajcujmy wszyscy!") |
| 17 | async def play( | 18 | async def play( |
| @@ -57,5 +58,12 @@ class Play(commands.Cog): | |||
| 57 | filename = await play_utils.PlayUtils(self.bot).compress(ctx, filename) | 58 | filename = await play_utils.PlayUtils(self.bot).compress(ctx, filename) |
| 58 | await play_utils.PlayUtils(self.bot).play(ctx, filename, title) | 59 | await play_utils.PlayUtils(self.bot).play(ctx, filename, title) |
| 59 | 60 | ||
| 61 | @discord.slash_command(name="grajcuj_plik", description="grajcuj plik") | ||
| 62 | async def play_file(self, ctx: discord.ApplicationContext, attachment: discord.Attachment = discord.Option(discord.Attachment, "co zagrać??", required=True)): | ||
| 63 | await ctx.defer() | ||
| 64 | file_path = os.path.join(self.temp_dir, attachment.filename) | ||
| 65 | await attachment.save(file_path) | ||
| 66 | await play_utils.PlayUtils(self.bot).play(ctx, file_path) | ||
| 67 | |||
| 60 | def setup(bot): | 68 | def setup(bot): |
| 61 | bot.add_cog(Play(bot)) \ No newline at end of file | 69 | bot.add_cog(Play(bot)) \ No newline at end of file |
