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 <ts6bot/MusicManager.hpp>
class Select : public Command
{
public:
void execute(const CommandContext& ctx) override
{
if (ctx.musicManager.expired()) {
return;
}
int idx = 0;
// High-performance string-to-int conversion
auto res = std::from_chars(ctx.args.data(),
ctx.args.data() + ctx.args.size(), idx);
if (res.ec == std::errc()) {
if (ctx.musicManager.lock()->selectSearchResult(
ctx.clientID, idx, std::string(ctx.invokerName))) {
ctx.reply("Selected song added to queue.");
} else {
ctx.reply("Invalid selection index.");
}
} else {
ctx.reply("Please provide a valid number.");
}
}
CommandCategory getCategory() const override
{
return CommandCategory::Music;
}
std::vector<std::string_view> getAliases() const override
{
return {"sel"};
}
std::string_view getDescription() const override
{
return "Selects a song from search results.";
}
std::string_view getUsage() const override { return "<number>"; }
};