#pragma once #include #include #include 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 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 ""; } };