public async Task Test(string type) { switch (type) { case "join": await Join.Send(Context.Message); break; case "part": await Part.Send(Context.Message); break; case "message": await Message.Send(Context.Message); break; case "achievement": await Achievement.Send(Context.Message); break; case "death": await Death.Send(Context.Message); break; case "srvcrash": await SrvCrash.Send(); break; case "srvstart": await SrvStart.Send(); break; case "srvstop": await SrvStop.Send(); break; } }
private async Task HandleCommandAsync(SocketMessage arg) { if (!(arg is SocketUserMessage msg)) { return; } var context = new SocketCommandContext(_client, msg); var pos = 0; if (msg.HasCharPrefix(']', ref pos)) { var result = await _commands.ExecuteAsync(context, pos, _services); if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { await msg.Channel.SendMessageAsync(result.ErrorReason); } // TODO: increment command counter return; } // Whitelist bot-spam if (msg.Channel.Id != 449886304117850132) { return; } // Whitelist webhook messages that don't come from ourself if (msg.Source != MessageSource.Webhook) { return; } switch (msg.DetectType()) { // TODO: increment each type counter case MsgType.Message: await Message.Send(msg); break; case MsgType.Join: await Join.Send(msg); break; case MsgType.Part: await Part.Send(msg); break; case MsgType.SrvStart: await SrvStart.Send(); break; case MsgType.SrvStop: await SrvStop.Send(); break; case MsgType.SrvCrash: await SrvCrash.Send(); break; case MsgType.Cmd: await Command.Send(msg); break; case MsgType.Death: await Death.Send(msg); break; case MsgType.Achievement: await Achievement.Send(msg); break; case null: Console.WriteLine("Found null msgType"); break; default: throw new ArgumentOutOfRangeException(); } }