예제 #1
0
        public async Task SentHecks(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);
            List <HeckTextRecord> hecks = utils.GetHecksSent(usr.ID);

            if (hecks.Count > 0)
            {
                var builder = new EmbedBuilder();
                int index   = 1;
                builder.WithTitle(dUser.Username + " Hecks Sent");

                foreach (HeckTextRecord heck in hecks)
                {
                    builder.AddField(index.ToString(), heck.Value);
                    index++;
                }
                builder.WithColor(Color.Red);
                Embed embed = builder.Build();
                await Context.Channel.SendMessageAsync("", false, embed);
            }
            else
            {
                await ReplyAsync($"Could not locate hecks sent for user.");
            }
        }
예제 #2
0
        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.");
            }
        }
예제 #3
0
        public HeckGuild GetHeckGuild(string SnowFlake, bool CreateIfNotExists)
        {
            HeckGuild      item  = null;
            HeckGuildModel model = new HeckGuildModel(null);
            DataResponse   resp  = model.GetGuildBySnowflake(SnowFlake);

            if (!resp.Result && CreateIfNotExists)
            {
                if (CreateHeckGuild(SnowFlake))
                {
                    resp = model.GetGuildBySnowflake(SnowFlake);
                }
            }
            if (resp != null)
            {
                item = resp.Item as HeckGuild;
            }
            model.Dispose();
            return(item);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public async Task Heck(string userm = null, [Remainder] string Name = null)
        {
            if (Context.Message.Author.IsBot)
            {
                return;
            }
            float?Value  = 1;
            IUser dMUser = null;

            if (Context.Message.ReferencedMessage != null)
            {
                dMUser = Context.Message.ReferencedMessage.Author;
                if (Context.Message.Content == "heck u")
                {
                    Name = "For your message: " + Context.Message.ReferencedMessage.Content;
                }
                else
                {
                    string heckReason = Context.Message.Content.Replace("&heck", "");

                    Name = heckReason;
                }
            }
            else
            {
                dMUser = Context.Message.MentionedUsers.FirstOrDefault();
            }
            if (dMUser == null)
            {
                await ReplyAsync("Go heck yourself! You must specify a user.");

                return;
            }
            if (Name == null)
            {
                await ReplyAsync("Get heck'd buddy! You must specify a reason to heck this person.");

                return;
            }
            if (dMUser.IsBot)
            {
                await ReplyAsync("Oh heck...That's a bot, bots are immune to hecks.");

                return;
            }
            HeckGuild guild = GetContextGuild();
            HeckUser  usr   = utils.GetHeckUser(Context.Message.Author.Id.ToString(), guild.ID, Context.Message.Author.Username, true);
            HeckUser  mUsr  = utils.GetHeckUser(dMUser.Id.ToString(), guild.ID, dMUser.Username, true);

            if ((Value ?? 0) == 0)
            {
                Value = 1;
            }
            if ((usr.AvailableHecks - Math.Abs(Value.Value)) < 0)
            {
                await ReplyAsync("Oh heck! You have don't have enough hecks left to give for that amount of heck.");

                return;
            }

            float nnValue = Value.Value;

            if (utils.CreateHeck(usr.ID, mUsr.ID, Name, nnValue))
            {
                await ReplyAsync($"Heck u {dMUser.Mention} \"" + Name + "\". You've received " + nnValue.ToString() + " heck(s).");
            }
            else
            {
                await ReplyAsync("Oh heck that's horrible, something went wrong.");
            }
        }