Files
faumaray 5c036d91fb making WEB
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-11 00:45:17 +03:00

63 lines
1.3 KiB
C++

#pragma once
#include "Command.hpp"
#include <CoreInterface.hpp>
#include <Void/Log/Log.hpp>
#include <format>
namespace Echoion::Core
{
class ReloadConfigCommand : public Command
{
public:
void execute(const CommandContext& ctx) override
{
try {
auto core = ctx.service<Api::ICoreInterface>();
if (!core) {
ctx.reply(
ctx.tr("Config reload is unavailable right now."));
return;
}
auto result = core->reloadConfig();
if (result) {
ctx.reply(
ctx.tr("✅ Configuration reloaded from disk."));
} else {
ctx.reply(std::string("❌ Failed to reload config: ") +
result.error().message);
}
} catch (const std::exception& e) {
Void::Log::error(
"ReloadConfigCommand",
"{}",
std::format("ReloadConfig command exception: {}",
e.what()));
ctx.reply(
ctx.tr("Something went wrong. Please try again."));
}
}
std::string_view getDescription() const override
{
return "Reloads the bot configuration from file.";
}
CommandCategory getCategory() const override
{
return CommandCategory::Admin;
}
bool requiresAdmin() const override { return true; }
std::vector<std::string_view> getAliases() const override
{
return {"reloadcfg", "rlcfg"};
}
};
} // namespace Echoion::Core