예제 #1
0
        public async Task ReactionRemovedAsync(
            Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            SocketGuildUser gUser = Program.Singleton.Client.GetGuild(573131665660968970).GetUser(reaction.UserId);

            if (reaction.MessageId.ToString() == Config.Bot.reactGender)
            {
                _ = gUser.RemoveRolesAsync(RolesGender.Intersect(gUser.Roles.Select(obj => (IRole)obj)));
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactHome)
            {
                _ = gUser.RemoveRolesAsync(RolesHome.Intersect(gUser.Roles.Select(obj => (IRole)obj)));
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactZodiac)
            {
                _ = gUser.RemoveRolesAsync(RolesZodiac.Intersect(gUser.Roles.Select(obj => (IRole)obj)));
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactMBTI)
            {
                _ = gUser.RemoveRolesAsync(RolesMBTI.Intersect(gUser.Roles.Select(obj => (IRole)obj)));
            }

            User user = User.Get(reaction.UserId);

            if (user == null)
            {
                return;
            }

            ActionParam action = new ActionParam("React", channel.Id);

            ActionManager.Singleton.OnAction(user, action, true);
        }
예제 #2
0
        public async Task ReactionAddedAsync(
            Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            SocketGuild     guild = Program.Singleton.Client.GetGuild(573131665660968970);
            SocketGuildUser gUser = guild.GetUser(reaction.UserId);

            if (gUser == null)
            {
                return;
            }

            IUser        iUser = reaction.User.Value;
            IUserMessage msg   = await cache.DownloadAsync();

            if (reaction.MessageId.ToString() == Config.Bot.reactGender)
            {
                await msg.RemoveReactionsAsync(iUser, EmotesGender.Where(obj => obj.Name != reaction.Emote.Name).ToArray());

                await gUser.RemoveRolesAsync(RolesGender.Intersect(gUser.Roles.Select(obj => (IRole)obj)));

                switch (reaction.Emote.Name)
                {
                case "male":
                    _ = gUser.AddRoleAsync(RolesGender.FirstOrDefault(obj => obj.Name.ToString() == "Male"));
                    break;

                case "female":
                    _ = gUser.AddRoleAsync(RolesGender.FirstOrDefault(obj => obj.Name.ToString() == "Female"));
                    break;

                case "other":
                    _ = gUser.AddRoleAsync(RolesGender.FirstOrDefault(obj => obj.Name.ToString() == "Other"));
                    break;

                default:
                    _ = msg.RemoveReactionAsync(reaction.Emote, iUser, RequestOptions.Default);
                    break;
                }
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactHome)
            {
                await msg.RemoveReactionsAsync(iUser, EmotesHome.Where(obj => obj.Name != reaction.Emote.Name).ToArray());

                await gUser.RemoveRolesAsync(RolesHome.Intersect(gUser.Roles.Select(obj => (IRole)obj)));


                switch (reaction.Emote.Name)
                {
                case "northamerica":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "North America"));
                    break;

                case "southamerica":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "South America"));
                    break;

                case "oceania":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "Oceania"));
                    break;

                case "europe":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "Europe"));
                    break;

                case "asia":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "Asia"));
                    break;

                case "africa":
                    _ = gUser.AddRoleAsync(RolesHome.FirstOrDefault(obj => obj.Name.ToString() == "Africa"));
                    break;

                default:
                    _ = msg.RemoveReactionAsync(reaction.Emote, iUser);
                    break;
                }
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactZodiac)
            {
                await msg.RemoveReactionsAsync(iUser, EmotesZodiac.Where(obj => obj.Name != reaction.Emote.Name).ToArray());

                await gUser.RemoveRolesAsync(RolesZodiac.Intersect(gUser.Roles.Select(obj => (IRole)obj)));

                switch (reaction.Emote.Name)
                {
                case "♒":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Aquarius"));
                    break;

                case "♓":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Pisces"));
                    break;

                case "♈":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Aries"));
                    break;

                case "♉":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Taurus"));
                    break;

                case "♊":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Gemini"));
                    break;

                case "♋":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Cancer"));
                    break;

                case "♌":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Leo"));
                    break;

                case "♍":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Virgo"));
                    break;

                case "♎":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Libra"));
                    break;

                case "♏":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Scorpio"));
                    break;

                case "♐":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Sagittarius"));
                    break;

                case "♑":
                    _ = gUser.AddRoleAsync(RolesZodiac.FirstOrDefault(obj => obj.Name.ToString() == "Capricorn"));
                    break;

                default:
                    _ = msg.RemoveReactionAsync(reaction.Emote, iUser);
                    break;
                }
            }
            else if (reaction.MessageId.ToString() == Config.Bot.reactMBTI)
            {
                await msg.RemoveReactionsAsync(iUser, EmotesMBTI.Where(obj => obj.Name != reaction.Emote.Name).ToArray());

                await gUser.RemoveRolesAsync(RolesMBTI.Intersect(gUser.Roles.Select(obj => (IRole)obj)));

                switch (reaction.Emote.Name)
                {
                case "intj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "INTJ"));
                    break;

                case "intp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "INTP"));
                    break;

                case "entj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ENTJ"));
                    break;

                case "entp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ENTP"));
                    break;

                case "infj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "INFJ"));
                    break;

                case "infp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "INFP"));
                    break;

                case "enfj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ENFJ"));
                    break;

                case "enfp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ENFP"));
                    break;

                case "istj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ISTJ"));
                    break;

                case "isfj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ISFJ"));
                    break;

                case "estj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ESTJ"));
                    break;

                case "esfj":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ESFJ"));
                    break;

                case "istp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ISTP"));
                    break;

                case "isfp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ISFP"));
                    break;

                case "estp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ESTP"));
                    break;

                case "esfp":
                    _ = gUser.AddRoleAsync(RolesMBTI.FirstOrDefault(obj => obj.Name.ToString() == "ESFP"));
                    break;

                default:
                    _ = msg.RemoveReactionAsync(reaction.Emote, iUser);
                    break;
                }
            }

            User user = User.Get(reaction.UserId);

            if (user == null)
            {
                return;
            }

            ActionParam action = new ActionParam("React", channel.Id);

            ActionManager.Singleton.OnAction(user, action);
        }