sharp-chat/SharpChat/Commands/MessageBroadcastCommand.cs

29 lines
865 B
C#
Raw Normal View History

using SharpChat.Events;
using SharpChat.Packet;
using System;
namespace SharpChat.Commands {
2024-05-14 22:17:25 +00:00
public class MessageBroadcastCommand : IChatCommand {
public bool IsMatch(ChatCommandContext ctx) {
return ctx.NameEquals("say")
|| ctx.NameEquals("broadcast");
}
public void Dispatch(ChatCommandContext ctx) {
if(!ctx.User.Permissions.HasFlag(ChatUserPermissions.Broadcast)) {
ctx.Chat.SendTo(ctx.User, new CommandNotAllowedErrorPacket(ctx.Name));
return;
}
ctx.Chat.DispatchEvent(new MessageCreateEvent(
SharpId.Next(),
string.Empty,
ctx.User,
DateTimeOffset.Now,
string.Join(' ', ctx.Args),
false, false, true
));
}
}
}