Ejemplo n.º 1
0
        public async Task ChangeAffinity(affinityType type, IUser user, SocketCommandContext Context)
        {
            try
            {
                AffinityStats stats = new AffinityStats();
                if (affinityDict.ContainsKey(user.Id))
                {
                    affinityDict.TryGetValue(user.Id, out stats);
                }
                switch (type)
                {
                case (affinityType.pat):
                    stats.pats++;
                    break;

                case (affinityType.hug):
                    stats.hugs++;
                    break;

                case (affinityType.kiss):
                    stats.kisses++;
                    break;

                case (affinityType.poke):
                    stats.pokes++;
                    break;

                case (affinityType.slap):
                    stats.slaps++;
                    break;

                default:
                    await Context.Channel.SendMessageAsync(":no_entry_sign: Something went horribly wrong :eyes:");

                    await SentryService.SendMessage("AFFINITY FAILED IN SWITCH");

                    break;
                }

                affinityDict.AddOrUpdate(
                    user.Id,
                    stats,
                    (key, oldValue) => stats);
                SaveDatabase();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                await SentryService.SendError(e, Context);
            }
        }
Ejemplo n.º 2
0
        public async Task GetAffinity(IUser user, SocketCommandContext Context)
        {
            try
            {
                if (!affinityDict.ContainsKey(user.Id))
                {
                    await Context.Channel.SendMessageAsync(":no_entry_sign: User did not receive any pats,hugs,kisses,pokes or slaps yet!");

                    return;
                }
                AffinityStats stats = new AffinityStats();
                affinityDict.TryGetValue(user.Id, out stats);
                var eb = new EmbedBuilder()
                {
                    Color  = new Color(4, 97, 247),
                    Footer = new EmbedFooterBuilder()
                    {
                        Text    = $"Requested by {Context.User.Username}#{Context.User.Discriminator}",
                        IconUrl = (Context.User.GetAvatarUrl())
                    },
                    Title        = $"Affinity stats of {user.Username}#{user.Discriminator}",
                    ThumbnailUrl = (user.GetAvatarUrl()),
                    Description  = $"" +
                                   $"Pats:     {stats.pats}\n" +
                                   $"Hugs:     {stats.hugs}\n" +
                                   $"Kisses:   {stats.kisses}\n" +
                                   $"Pokes:    {stats.pokes}\n" +
                                   $"Slaps:    {stats.slaps}\n" +
                                   $"Affinity: {stats.GetAffinity()}/100"
                };

                await Context.Channel.SendMessageAsync("", false, eb);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                await SentryService.SendError(e, Context);
            }
        }