Files
faumaray 1153721546 go into command manager
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
2026-01-27 23:29:04 +03:00

46 lines
1.1 KiB
C++

#pragma once
#include <Command/Interface.hpp>
#include <charconv>
#include <format>
#include <ts6bot/MusicManager.hpp>
class Playlist : public Command
{
public:
void execute(const CommandContext& ctx) override
{
if (ctx.musicManager.expired()) {
LOG_ERROR("MusicManager is expired");
return;
}
std::string args(ctx.args);
std::string invoker(ctx.invokerName);
if (args.find("http") == 0) {
if (auto plId =
ctx.musicManager.lock()->extractPlaylistId(args)) {
if (ctx.musicManager.lock()->playPlaylist(*plId, invoker)) {
ctx.reply("Added PlayList to queue.");
} else {
ctx.reply("Failed to add playlist into the queue");
}
}
}
}
CommandCategory getCategory() const override
{
return CommandCategory::Music;
}
std::vector<std::string_view> getAliases() const override { return {}; }
std::string_view getDescription() const override
{
return "Plays all songs from URL of YouTube playlist";
}
std::string_view getUsage() const override
{
return "<url which contains \"list=\">";
}
};