sharp-chat/SharpChat/Commands/BroadcastCommand.cs
flashwave 8c19c22736 Reworking event dispatching... I think?
I did this make in february but left it uncommitted. Hopefully it's stable!
2023-07-23 21:31:13 +00:00

28 lines
872 B
C#

using SharpChat.Events;
using SharpChat.Packet;
using System;
namespace SharpChat.Commands {
public class BroadcastCommand : IChatCommand {
public bool IsMatch(ChatCommandContext ctx) {
return ctx.NameEquals("say")
|| ctx.NameEquals("broadcast");
}
public void Dispatch(ChatCommandContext ctx) {
if(!ctx.User.Can(ChatUserPermissions.Broadcast)) {
ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return;
}
ctx.Chat.DispatchEvent(new MessageCreateEvent(
SharpId.Next(),
string.Empty,
ctx.User,
DateTimeOffset.Now,
string.Join(' ', ctx.Args),
false, false, true
));
}
}
}