Files
Echoion/include/Core/Command/Select.hpp
T
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 <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>"; }
};