public async Task <PlayerStatic> ListOwnerServersInChannel(SocketCommandContext Context) { ulong serverID = 0; string servers = ""; int k = 1; Dictionary <string, ulong> userControlledservers = new Dictionary <string, ulong>(); foreach (var g in Context.Client.Guilds) { if (Context.User.Id == g.Owner.Id) { if (PlayerStatic.DoesProfileExist(g.Id)) { userControlledservers.Add(g.Name, g.Id); servers += $" * {g.Name} \n"; k++; } } } if (userControlledservers.Count > 1) { await ReplyAsync($"You control the following servers:\n{servers} Please enter the name of the server you want to select, it does not have to be the full name."); var serverNameResponse = await NextMessageAsync(true, false, timeout : TimeSpan.FromMinutes(5)); foreach (var u in userControlledservers) { if (u.Key.ToLower().Contains(serverNameResponse.Content.ToLower())) { serverID = u.Value; break; } } } else { serverID = userControlledservers.Values.First(); } PlayerStatic ps = PlayerStatic.Load(serverID); return(ps); }
public async Task ListStaticsWithJobFilter([Remainder] string job) { var reply = new List <string>(); reply.Add(""); var files = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, $"statics/")); int i = 0; int pageIndex = 0; foreach (var file in files) { ulong servId = Convert.ToUInt64(Path.GetFileNameWithoutExtension(file)); var ps = PlayerStatic.Load(servId); if (ps.recruiting == true) { if (ps.Filters.Contains(job.ToLower())) { if ((i % 10 == 0 && i != 1 && i != 0)) { reply.Add($"{ps.PlayerStaticName}\n"); i++; pageIndex++; } else { reply[pageIndex] += ps.PlayerStaticName + "\n"; i++; } } } } Console.WriteLine($"{files.Count()} files found"); var message = new Discord.Addons.Interactive.PaginatedMessage(); message.Title = $"{files.Count()} Statics"; message.Color = new Color(250, 140, 73); message.Pages = reply; await PagedReplyAsync(reply); }
public async Task <PlayerStatic> ListOwnerServers(SocketCommandContext Context) { ulong serverID = 0; string servers = ""; int k = 1; Dictionary <string, ulong> userControlledservers = new Dictionary <string, ulong>(); foreach (var g in Context.Client.Guilds) { if (Context.User.Id == g.Owner.Id) { if (PlayerStatic.DoesProfileExist(g.Id)) { userControlledservers.Add(g.Name, g.Id); servers += $" {k}. {g.Name} \n"; k++; } } } if (userControlledservers.Count > 1) { await Context.User.SendMessageAsync($"You control the following servers:\n{servers} Please enter the number of the server you want to select."); var serverNameResponse = await NextMessageAsync(true, false, timeout : TimeSpan.FromMinutes(5)); int responseInt = Convert.ToInt32(serverNameResponse.Content); serverID = userControlledservers.ElementAt(responseInt - 1).Value; await Context.User.SendMessageAsync($"You have selected: **{userControlledservers.ElementAt(responseInt-1).Key}**"); } else { serverID = userControlledservers.Values.First(); } PlayerStatic ps = PlayerStatic.Load(serverID); return(ps); }
public async Task JoinStatic([Remainder] string input) { if (Player.DoesProfileExist(Context.User.Id) == false) { await Context.User.SendMessageAsync("Please run the command !n add profile `world` `firstname lastname` first."); return; } var staticNameR = input; var serv = Context.Client.Guilds; var results = from server in serv where server.Name.ToLower().Contains(staticNameR.ToLower()) select server; if (results.Count() == 0) { await Context.User.SendMessageAsync($"Error: Static server `{staticNameR} not found"); return; } PlayerStatic ps = PlayerStatic.Load(results.First().Id); Player playa = Player.Load(Context.User.Id); if (playa.dc.ToLower() != ps.dc.ToLower()) { await Context.User.SendMessageAsync($"You are not located in the {ps.dc} datacenter"); } if (!ps.Applications.ContainsValue(Context.User.Id) && !ps.Members.ContainsValue(Context.User.Id)) { if (ps.Filters.Count == 0) { ps.Applications.Add(Context.User.Username.ToLower(), Context.User.Id); ps.EnsureExists(); var fflogs = new fflogs(); Console.WriteLine("sending profile"); Embed embed = await fflogs.SendProfileReply(Context.User.Id); Console.WriteLine("profile sent"); await results.First().Owner.SendMessageAsync($"New Application from {Context.User.Username}, use !n static applications to approve/deny the application", embed: embed); } else { foreach (var filt in ps.Filters) { //Job Filter if (filt.Length == 3) { foreach (var jb in playa.jobs) { if (filt.ToLower() == jb.short_name) { ps.Applications.Add(Context.User.Username.ToLower(), Context.User.Id); ps.EnsureExists(); var fflogs = new fflogs(); Embed embed = await fflogs.SendProfileReply(Context.User.Id); await Context.User.SendMessageAsync("Application sent"); await results.First().Owner.SendMessageAsync($"New Application from {Context.User.Username}, use !n static applications to approve/deny the application", embed: embed); } else { await Context.User.SendMessageAsync("Requirements not met"); } } } // Cleared Fights Filter else { foreach (var clrd in playa.cleared) { if (filt.ToLower().Contains(clrd.ToLower())) { ps.Applications.Add(Context.User.Username.ToLower(), Context.User.Id); ps.EnsureExists(); var fflogs = new fflogs(); Embed embed = await fflogs.SendProfileReply(Context.User.Id); await Context.User.SendMessageAsync("Application sent"); await results.First().Owner.SendMessageAsync($"New Application from {Context.User.Username}, use !n static applications to approve/deny the application", embed: embed); } else { await Context.User.SendMessageAsync("Requirements not met"); } } } } } } else { await Context.User.SendMessageAsync($"You are either already a member of {ps.PlayerStaticName} or have already sent in an application"); } }