public async Task PutServerInfo(string ip, int port, string serverName) { if (await this.serverService.Exists(Context.Guild.Id, ip, port)) { await ReplyAsync("This server is already registered with this bot."); } if (!System.Net.IPAddress.TryParse(ip, out _)) { await ReplyAsync("Wrong IP address!"); return; } if (NetworkPort.IsCorrect(port) == false) { await ReplyAsync("Wrong port!"); return; } await this.serverService.Getsert(Context.Guild.Id, ip, port, serverName); await ReplyAsync("Server has been registered."); }
public async Task SubscribeToServer(string serverName, int port) { var server = await serverService.Get(Context.Guild.Id, serverName); if (server == null) { await ReplyAsync("Server does not exist!"); return; } if (await SubscribedServerService.Exists(Context.Guild.Id, server.ServerName, Context.Channel.Id)) { await ReplyAsync("Server is already registered here!"); return; } if (NetworkPort.IsCorrect(port) == false) { await ReplyAsync("Wrong port!"); return; } await SubscribedServerService.AddServer(Context.Guild.Id, server.ServerName, port, Context.Channel.Id); await ReplyAsync("Done!"); return; }