Delete the echoion Logger adapter (Logger.{hpp,cpp}) and the
ILogger/LoggerRegistry indirection. Core::installLogging() builds the
console + split-file Void::Logging::MultiLogger and installs it as the
process-wide Void::Log sink via Void::Log::make_sink (logSink_ owns it for
the process lifetime). The ~450 ECHOION_LOG_* call sites across EchoionCore
are rewritten to Void::Log::<level>("<Subsystem>", "{}", <expr>) with
per-file module tags (warning->warn, critical->fatal); the pre-formatted
message is passed as the single "{}" argument. Build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
93 lines
2.2 KiB
C++
93 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "Command.hpp"
|
|
#include <Void/Log/Log.hpp>
|
|
#include <charconv>
|
|
#include <format>
|
|
|
|
namespace Echoion::Core
|
|
{
|
|
|
|
class SelectCommand : public Command
|
|
{
|
|
public:
|
|
|
|
void execute(const CommandContext& ctx) override
|
|
{
|
|
try {
|
|
auto manager = ctx.musicManager.lock();
|
|
if (!manager) {
|
|
ctx.reply(
|
|
"The music service is currently unavailable.");
|
|
return;
|
|
}
|
|
|
|
if (ctx.args.empty()) {
|
|
ctx.reply("Usage: select <number>\nSelect a track from "
|
|
"your last search results.");
|
|
return;
|
|
}
|
|
|
|
// Parse index
|
|
uint32_t index = 0;
|
|
auto result =
|
|
std::from_chars(ctx.args.data(),
|
|
ctx.args.data() + ctx.args.size(),
|
|
index);
|
|
if (result.ec != std::errc() || index == 0) {
|
|
ctx.reply(
|
|
"Please provide a valid number (1, 2, 3, etc.).");
|
|
return;
|
|
}
|
|
|
|
std::string invokerName(ctx.invokerName);
|
|
auto selectResult = manager->selectSearchResult(
|
|
ctx.clientId, index, invokerName);
|
|
|
|
if (!selectResult) {
|
|
Void::Log::error("SelectCommand", "{}", std::format(
|
|
"Select failed for client {} index {}: {}",
|
|
ctx.clientId, index, selectResult.error().message));
|
|
|
|
if (selectResult.error().code ==
|
|
Api::ErrorCode::NotFound) {
|
|
ctx.reply(std::format(
|
|
"No search results found. Use {}play "
|
|
"<query> to search first.",
|
|
ctx.prefix));
|
|
} else {
|
|
ctx.reply("Couldn't select that track. Please try "
|
|
"again.");
|
|
}
|
|
return;
|
|
}
|
|
|
|
ctx.reply(*selectResult);
|
|
|
|
} catch (const std::exception& e) {
|
|
Void::Log::error("SelectCommand", "{}",
|
|
std::format("Select command exception: {}", e.what()));
|
|
ctx.reply("Something went wrong. Please try again.");
|
|
}
|
|
}
|
|
|
|
std::string_view getDescription() const override
|
|
{
|
|
return "Selects a track from your search results.";
|
|
}
|
|
|
|
std::string_view getUsage() const override { return "<number>"; }
|
|
|
|
CommandCategory getCategory() const override
|
|
{
|
|
return CommandCategory::Music;
|
|
}
|
|
|
|
std::vector<std::string_view> getAliases() const override
|
|
{
|
|
return {"sel", "pick", "choose"};
|
|
}
|
|
};
|
|
|
|
} // namespace Echoion::Core
|