public UserHeckTotal GetUserHeckTotal(int UserID) { UserHeckTotal item = null; HeckProcedureModel model = new HeckProcedureModel(null); DataResponse resp = model.GetUserHeckTotal(UserID); if (resp != null) { item = resp.Item as UserHeckTotal; } model.Dispose(); return(item); }
public async Task Info(string userm = null) { if (Context.Message.Author.IsBot) { return; } HeckGuild guild = GetContextGuild(); IUser dUser = null; if (string.IsNullOrWhiteSpace(userm)) { dUser = Context.Message.Author; } else { dUser = Context.Message.MentionedUsers.FirstOrDefault(); } if (dUser == null) { await ReplyAsync("Go heck yourself! You must specify a user."); return; } if (dUser.IsBot) { await ReplyAsync("Oh heck...That's a bot, bots are immune to hecks."); return; } HeckUser usr = utils.GetHeckUser(dUser.Id.ToString(), guild.ID, dUser.Username, true); UserHeckTotal userHeckTotal = utils.GetUserHeckTotal(usr.ID); if (userHeckTotal != null) { await ReplyAsync($"Your current heck total weight with buffs is: " + userHeckTotal.HecksWeighted.ToString() + "\r\nYour current heck weight total is: " + userHeckTotal.WeightTotal.ToString() + "\r\nYour current heck(s) unweighted is: " + userHeckTotal.HeckTotal.ToString() + "\r\nYour available heck(s) to heck with is: " + userHeckTotal.AvailableHecks.ToString() + $"\r\n\r\nGo heck yourself, {dUser.Mention}!"); } else { await ReplyAsync($"Could not locate info for user."); } }
public List <UserHeckTotal> GetLeaderboard(SocketCommandContext Context) { IGuild dGuild = Context.Guild; HeckGuild guild = GetHeckGuild(dGuild.Id.ToString(), true); List <HeckUser> usrs = null; List <UserHeckTotal> lst = new List <UserHeckTotal>(); HeckUserModel mdl = new HeckUserModel(null); usrs = mdl.GetAllUsersByGuildID(guild.ID); mdl.Dispose(); foreach (HeckUser usr in usrs) { UserHeckTotal ttl = GetUserHeckTotal(usr.ID); if (ttl != null) { IUser dUser = null; try { dUser = Context.Guild.GetUser(Convert.ToUInt64(usr.Snowflake)); } catch (Exception ex) { Console.WriteLine("Error occured while getting guild user by " + usr.Snowflake + ". Message: " + ex.Message); } if (dUser == null) { Console.WriteLine("Could not find user in guild by snowflake: " + usr.Snowflake); continue; } if (dUser.IsBot) { continue; } ttl.User.UserName = dUser.Username; lst.Add(ttl); } } lst = lst.OrderByDescending(o => o.HecksWeighted).ToList(); return(lst); }