Files
EchoionCore/include/echoion/core/commands/AnnounceCommand.hpp
T
faumaray d146f11f02 Release 1.0.0
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-04 01:49:28 +03:00

56 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("The music service is currently unavailable.");
return;
}
if (ctx.args.empty()) {
ctx.reply(std::format(
"Usage: {}announce <message>", ctx.prefix));
return;
}
const size_t reached = manager->setAnnouncement(ctx.args);
ctx.reply(std::format(
"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