Compare commits
No commits in common. "e85d90fb36b7ab6e2a58ebcb8bc45e41d5b5ad5e" and "786de8412b81c905c3de2dee8790ea90afb1576c" have entirely different histories.
e85d90fb36
...
786de8412b
@ -33,6 +33,24 @@ async def uptime(message):
|
|||||||
if args.since:
|
if args.since:
|
||||||
await utils.reply(message, f"{round(start_time)}")
|
await utils.reply(message, f"{round(start_time)}")
|
||||||
else:
|
else:
|
||||||
await utils.reply(
|
format_plural = lambda noun, count: noun if count == 1 else noun + "s"
|
||||||
message, f"up {utils.format_duration(int(time.time() - start_time))}"
|
|
||||||
)
|
segments = []
|
||||||
|
duration = int(time.time() - start_time)
|
||||||
|
|
||||||
|
days, duration = divmod(duration, 86400)
|
||||||
|
if days >= 1:
|
||||||
|
segments.append(f"{days} {format_plural('day', days)}")
|
||||||
|
|
||||||
|
hours, duration = divmod(duration, 3600)
|
||||||
|
if hours >= 1:
|
||||||
|
segments.append(f"{hours} {format_plural('hour', hours)}")
|
||||||
|
|
||||||
|
minutes, duration = divmod(duration, 60)
|
||||||
|
if minutes >= 1:
|
||||||
|
segments.append(f"{minutes} {format_plural('minute', minutes)}")
|
||||||
|
|
||||||
|
if duration > 0:
|
||||||
|
segments.append(f"{duration} {format_plural('second', duration)}")
|
||||||
|
|
||||||
|
await utils.reply(message, f"up {', '.join(segments)}")
|
||||||
|
@ -18,26 +18,27 @@ async def queue_or_play(message):
|
|||||||
tokens[0], "queue a song, list the queue, or resume playback"
|
tokens[0], "queue a song, list the queue, or resume playback"
|
||||||
)
|
)
|
||||||
parser.add_argument("query", nargs="?", help="yt-dlp URL or query to get song")
|
parser.add_argument("query", nargs="?", help="yt-dlp URL or query to get song")
|
||||||
parser.add_argument(
|
group = parser.add_mutually_exclusive_group()
|
||||||
|
group.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--volume",
|
"--volume",
|
||||||
default=50,
|
default=50,
|
||||||
type=lambda v: arguments.range_type(v, min=0, max=150),
|
type=lambda v: arguments.range_type(v, min=0, max=150),
|
||||||
help="the volume level (0 - 150)",
|
help="the volume level (0 - 150)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"-i",
|
"-i",
|
||||||
"--remove-index",
|
"--remove-index",
|
||||||
type=int,
|
type=int,
|
||||||
help="remove a queued song by index",
|
help="remove a queued song by index",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"-m",
|
"-m",
|
||||||
"--remove-multiple",
|
"--remove-multiple",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="continue removing queued songs after finding a match",
|
help="continue removing queued songs after finding a match",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--clear",
|
"--clear",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@ -60,30 +61,10 @@ async def queue_or_play(message):
|
|||||||
type=int,
|
type=int,
|
||||||
help="remove queued songs by queuer",
|
help="remove queued songs by queuer",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"-d",
|
|
||||||
"--duration",
|
|
||||||
action="store_true",
|
|
||||||
help="print duration of queued songs",
|
|
||||||
)
|
|
||||||
if not (args := await parser.parse_args(message, tokens)):
|
if not (args := await parser.parse_args(message, tokens)):
|
||||||
return
|
return
|
||||||
|
|
||||||
if args.duration:
|
if args.clear:
|
||||||
queued_songs = players[message.guild.id].queue
|
|
||||||
formatted_duration = utils.format_duration(
|
|
||||||
sum(
|
|
||||||
[
|
|
||||||
queued.player.duration if queued.player.duration else 0
|
|
||||||
for queued in queued_songs
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await utils.reply(
|
|
||||||
message,
|
|
||||||
f"queue is **{formatted_duration or '0 seconds'}** long (**{len(queued_songs)}** songs queued)",
|
|
||||||
)
|
|
||||||
elif args.clear:
|
|
||||||
players[message.guild.id].queue.clear()
|
players[message.guild.id].queue.clear()
|
||||||
await utils.add_check_reaction(message)
|
await utils.add_check_reaction(message)
|
||||||
return
|
return
|
||||||
|
22
utils.py
22
utils.py
@ -3,28 +3,6 @@ import disnake
|
|||||||
import constants
|
import constants
|
||||||
|
|
||||||
|
|
||||||
def format_duration(duration: int):
|
|
||||||
format_plural = lambda noun, count: noun if count == 1 else noun + "s"
|
|
||||||
segments = []
|
|
||||||
|
|
||||||
days, duration = divmod(duration, 86400)
|
|
||||||
if days >= 1:
|
|
||||||
segments.append(f"{days} {format_plural('day', days)}")
|
|
||||||
|
|
||||||
hours, duration = divmod(duration, 3600)
|
|
||||||
if hours >= 1:
|
|
||||||
segments.append(f"{hours} {format_plural('hour', hours)}")
|
|
||||||
|
|
||||||
minutes, duration = divmod(duration, 60)
|
|
||||||
if minutes >= 1:
|
|
||||||
segments.append(f"{minutes} {format_plural('minute', minutes)}")
|
|
||||||
|
|
||||||
if duration > 0:
|
|
||||||
segments.append(f"{duration} {format_plural('second', duration)}")
|
|
||||||
|
|
||||||
return ", ".join(segments)
|
|
||||||
|
|
||||||
|
|
||||||
async def add_check_reaction(message):
|
async def add_check_reaction(message):
|
||||||
await message.add_reaction("✅")
|
await message.add_reaction("✅")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user