58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "Command.hpp"
|
|
#include <CoreInterface.hpp>
|
|
#include <Void/Log/Log.hpp>
|
|
#include <format>
|
|
|
|
namespace Echoion::Core
|
|
{
|
|
|
|
class ReloadCommand : public Command
|
|
{
|
|
public:
|
|
|
|
void execute(const CommandContext& ctx) override
|
|
{
|
|
Void::Log::info("ReloadCommand", "{}",
|
|
"Reload requested by user");
|
|
|
|
// Reload configuration from disk. A full core/plugin reload is
|
|
// driven from the TS plugin menu (that lives in the plugin).
|
|
if (auto core = ctx.service<Api::ICoreInterface>()) {
|
|
auto result = core->reloadConfig();
|
|
if (result) {
|
|
ctx.reply(
|
|
ctx.tr("✅ Configuration reloaded. For a full core "
|
|
"reload, use the TS plugin menu."));
|
|
} else {
|
|
ctx.reply(std::string("❌ Config reload failed: ") +
|
|
result.error().message);
|
|
}
|
|
} else {
|
|
ctx.reply(
|
|
ctx.tr("Reload is handled by the plugin. Use the TS "
|
|
"plugin menu to reload the core."));
|
|
}
|
|
}
|
|
|
|
std::string_view getDescription() const override
|
|
{
|
|
return "Shows information about reloading the bot.";
|
|
}
|
|
|
|
CommandCategory getCategory() const override
|
|
{
|
|
return CommandCategory::Admin;
|
|
}
|
|
|
|
bool requiresAdmin() const override { return true; }
|
|
|
|
std::vector<std::string_view> getAliases() const override
|
|
{
|
|
return {"restart", "r"};
|
|
}
|
|
};
|
|
|
|
} // namespace Echoion::Core
|