le async has arrived

This commit is contained in:
flash 2025-04-26 22:28:41 +00:00
commit 7bdf41a047
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
27 changed files with 282 additions and 309 deletions
SharpChat/ClientCommands

View file

@ -1,4 +1,4 @@
using SharpChat.S2CPackets;
using SharpChat.S2CPackets;
namespace SharpChat.ClientCommands {
public class JoinChannelClientCommand : ClientCommand {
@ -6,18 +6,18 @@ namespace SharpChat.ClientCommands {
return ctx.NameEquals("join");
}
public void Dispatch(ClientCommandContext ctx) {
public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next();
string joinChanStr = ctx.Args.FirstOrDefault() ?? "Channel";
Channel? joinChan = ctx.Chat.Channels.FirstOrDefault(c => c.NameEquals(joinChanStr));
if(joinChan is null) {
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.CHANNEL_NOT_FOUND, true, joinChanStr));
ctx.Chat.ForceChannel(ctx.User);
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.CHANNEL_NOT_FOUND, true, joinChanStr));
await ctx.Chat.ForceChannel(ctx.User);
return;
}
ctx.Chat.SwitchChannel(ctx.User, joinChan, string.Join(' ', ctx.Args.Skip(1)));
await ctx.Chat.SwitchChannel(ctx.User, joinChan, string.Join(' ', ctx.Args.Skip(1)));
}
}
}