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

57 lines
1.4 KiB
C++

#pragma once
#include "../MusicManager.hpp"
#include "Command.hpp"
#include <format>
namespace Echoion::Core
{
// !announce <text> — admin-only. Stores the announcement and delivers it
// as a private message to each subscriber exactly once: to those online
// now, and to others the next time they connect. Persisted per-uid, so a
// bot restart never re-sends, and re-running !announce with new text
// reaches everyone once more.
class AnnounceCommand : public Command
{
public:
void execute(const CommandContext& ctx) override
{
auto manager = ctx.musicManager.lock();
if (!manager) {
ctx.reply(
ctx.tr("The music service is currently unavailable."));
return;
}
if (ctx.args.empty()) {
ctx.reply(
ctx.trf("Usage: {}announce <message>", ctx.prefix));
return;
}
const size_t reached = manager->setAnnouncement(ctx.args);
ctx.reply(ctx.trf(
"Announcement saved and delivered to {} online "
"subscriber(s). Offline subscribers get it on their "
"next connect.",
reached));
}
std::string_view getDescription() const override
{
return "Send an announcement to all subscribers (admin).";
}
std::string_view getUsage() const override { return "<message>"; }
CommandCategory getCategory() const override
{
return CommandCategory::Admin;
}
bool requiresAdmin() const override { return true; }
};
} // namespace Echoion::Core