feat(commands/voice/playing): add --description
This commit is contained in:
parent
d9d35a2672
commit
d3fd79e87f
@ -216,17 +216,50 @@ async def playing(message):
|
||||
if not command_allowed(message):
|
||||
return
|
||||
|
||||
tokens = commands.tokenize(message.content)
|
||||
parser = arguments.ArgumentParser(
|
||||
tokens[0], "get information about the currently playing song"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--description",
|
||||
action="store_true",
|
||||
help="get the description",
|
||||
)
|
||||
if not (args := await parser.parse_args(message, tokens)):
|
||||
return
|
||||
|
||||
if source := message.guild.voice_client.source:
|
||||
if args.description:
|
||||
if description := source.description:
|
||||
paginator = disnake_paginator.ButtonPaginator(
|
||||
invalid_user_function=utils.invalid_user_handler,
|
||||
color=constants.EMBED_COLOR,
|
||||
title=source.title,
|
||||
segments=disnake_paginator.split(description),
|
||||
)
|
||||
for embed in paginator.embeds:
|
||||
embed.url = source.original_url
|
||||
await paginator.start(
|
||||
disnake_paginator.wrappers.MessageInteractionWrapper(message)
|
||||
)
|
||||
else:
|
||||
await utils.reply(
|
||||
message,
|
||||
source.description or "no description found!",
|
||||
)
|
||||
return
|
||||
|
||||
bar_length = 35
|
||||
progress = source.original.progress / source.duration
|
||||
|
||||
embed = disnake.Embed(
|
||||
color=constants.EMBED_COLOR,
|
||||
title=source.title,
|
||||
url=source.original_url,
|
||||
description=f"{'⏸️ ' if message.guild.voice_client.is_paused() else ''}"
|
||||
f"`[{'#'*int(progress * bar_length)}{'-'*int((1 - progress) * bar_length)}]` "
|
||||
f"**{youtubedl.format_duration(int(source.original.progress))}** / **{youtubedl.format_duration(source.duration)}** (**{round(progress * 100)}%**)",
|
||||
url=source.original_url,
|
||||
)
|
||||
embed.add_field(name="Volume", value=f"{int(source.volume*100)}%")
|
||||
embed.add_field(name="Views", value=f"{source.view_count:,}")
|
||||
|
@ -3,11 +3,10 @@ import collections
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Optional
|
||||
|
||||
import constants
|
||||
import disnake
|
||||
import yt_dlp
|
||||
|
||||
import constants
|
||||
|
||||
ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS)
|
||||
|
||||
|
||||
@ -33,6 +32,7 @@ class YTDLSource(disnake.PCMVolumeTransformer):
|
||||
):
|
||||
super().__init__(source, volume)
|
||||
|
||||
self.description = data.get("description")
|
||||
self.duration = data.get("duration")
|
||||
self.original_url = data.get("original_url")
|
||||
self.thumbnail_url = data.get("thumbnail")
|
||||
|
Loading…
x
Reference in New Issue
Block a user