go into command manager

Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-01-27 23:29:04 +03:00
1 parent b94b634a87
commit 1153721546
19 files changed
+752 -229

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#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=\">";
}
};