If you were still handling message ids as integers in an environment that can't handle signed 64-bit integers you're going to be having a fun time after this update!
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using SharpChat.Misuzu;
|
|
using SharpChat.Packet;
|
|
|
|
namespace SharpChat.Commands {
|
|
public class BanListCommand(MisuzuClient msz) : IChatCommand {
|
|
private readonly MisuzuClient Misuzu = msz ?? throw new ArgumentNullException(nameof(msz));
|
|
|
|
public bool IsMatch(ChatCommandContext ctx) {
|
|
return ctx.NameEquals("bans")
|
|
|| ctx.NameEquals("banned");
|
|
}
|
|
|
|
public void Dispatch(ChatCommandContext ctx) {
|
|
long msgId = ctx.Chat.RandomSnowflake.Next();
|
|
|
|
if(!ctx.User.Can(ChatUserPermissions.BanUser | ChatUserPermissions.KickUser)) {
|
|
ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
|
|
return;
|
|
}
|
|
|
|
Task.Run(async () => {
|
|
MisuzuBanInfo[]? mbi = await Misuzu.GetBanListAsync();
|
|
|
|
if(mbi is null)
|
|
ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(msgId, LCR.GENERIC_ERROR, true));
|
|
else
|
|
ctx.Chat.SendTo(ctx.User, new BanListPacket(msgId, mbi));
|
|
}).Wait();
|
|
}
|
|
}
|
|
}
|