Пример #1
0
 private Task OnReactionAdded(Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
 {
     Core.Log.Write(Core.Log.Type.CHAT, "Message " + arg1.Id + " in " + arg2.GetPath() + " had a reaction " + arg3.Emote.Name + " added by " + arg3.User.Value?.ToStringOrNull() + ".");
     return(Task.CompletedTask);
 }
Пример #2
0
        private async Task OnReaction(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel chan, SocketReaction reaction)
        {
            if (!IsValidReaction(chan, reaction))
            {
                return;
            }

            IGuildUser guser = (IGuildUser)reaction.User.Value;

            if (!this.Players.TryGetValue(guser.GuildId, out IEnergizePlayer ply) || guser.VoiceChannel == null)
            {
                return;
            }
            if (!IsValidTrackPlayer(ply.TrackPlayer, cache.Id))
            {
                return;
            }

            await ReactionCallbacks[reaction.Emote.Name](this, ply);

            if (ply.CurrentRadio != null)
            {
                await ply.TrackPlayer.Update(ply.CurrentRadio, ply.Volume, ply.IsPaused, ply.IsLooping);
            }
            else
            {
                await ply.TrackPlayer.Update(ply.CurrentTrack, ply.Volume, ply.IsPaused, ply.IsLooping);
            }
        }
Пример #3
0
 private async Task HandleReactionAsync(Cacheable <IUserMessage, ulong> cacheable, ISocketMessageChannel messageChannel, SocketReaction reaction)
 {
     if (!reaction.User.Value.IsBot && PollHelper.IsMessagePoll(reaction.MessageId))
     {
         await PollHelper.VoteOnPollAsync(reaction, client);
     }
 }
Пример #4
0
        private async Task checkSub(Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            if (arg2.Id == Global.SubmissionChanID)
            {
                foreach (var item in Global.SubsList)
                {
                    Global.ConsoleLog("Error, Reaction Message doesnt exist, Using ID to get message", ConsoleColor.Red);

                    var linkmsg = _client.GetGuild(Global.SwissGuildId).GetTextChannel(Global.SubmissionChanID).GetMessageAsync(arg3.MessageId).Result;
                    if (item.linkMsg.Content == linkmsg.Content)
                    {
                        if (!arg3.User.Value.IsBot) //not a bot
                        {
                            string rs = "";
                            if (arg3.Emote.Name == item.checkmark.Name)
                            {
                                //good img
                                string curr = File.ReadAllText(Global.ButterFile);
                                File.WriteAllText(Global.ButterFile, curr + "\n" + item.url);
                                Global.ConsoleLog($"the image {item.url} has been approved by {arg3.User.Value.Username}#{arg3.User.Value.Discriminator}");
                                try { await _client.GetUser(item.SubmitterID).SendMessageAsync($"Your butter submission was approved by {arg3.User.Value.Username}#{arg3.User.Value.Discriminator} ({item.url})"); }
                                catch (Exception ex) { Global.ConsoleLog($"Error, {ex.Message}", ConsoleColor.Red); }
                                await item.botMSG.DeleteAsync();

                                await item.linkMsg.DeleteAsync();

                                Global.SubsList.Remove(item);
                                rs = "Accepted";
                            }
                            if (arg3.Emote.Name == item.Xmark.Name)
                            {
                                //bad img
                                Global.ConsoleLog($"the image {item.url} has been Denied by {arg3.User.Value.Username}#{arg3.User.Value.Discriminator}", ConsoleColor.Red);
                                await item.botMSG.DeleteAsync();

                                await item.linkMsg.DeleteAsync();

                                Global.SubsList.Remove(item);
                                try { await _client.GetUser(item.SubmitterID).SendMessageAsync($"Your butter submission was approved by {arg3.User.Value.Username}#{arg3.User.Value.Discriminator} ({item.url})"); }
                                catch (Exception ex) { Global.ConsoleLog($"Error, {ex.Message}", ConsoleColor.Red); }
                                rs = "Denied";
                            }

                            EmbedBuilder eb = new EmbedBuilder()
                            {
                                Title       = "Submission Result",
                                Color       = Color.Blue,
                                Description = $"The image {item.url} Submitted by {_client.GetUser(item.SubmitterID).Mention} has been **{rs}** by {arg3.User.Value.Mention} ({arg3.User.Value.Username}#{arg3.User.Value.Discriminator})",
                                Footer      = new EmbedFooterBuilder()
                                {
                                    Text    = "Result Autogen",
                                    IconUrl = _client.CurrentUser.GetAvatarUrl()
                                }
                            };
                            await _client.GetGuild(Global.SwissGuildId).GetTextChannel(Global.SubmissionsLogChanID).SendMessageAsync("", false, eb.Build());

                            return;
                        }
                    }
                }
            }
        }
Пример #5
0
        private async Task HelperReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var embed = message.Embeds.FirstOrDefault();

            if (embed.Title != PlayerResources.HelperTitle)
            {
                return;
            }

            int StatValue = 0;

            if (reaction.Emote.IsSameAs(GenericReactions.oneEmoji))
            {
                StatValue = 1;
            }
            if (reaction.Emote.IsSameAs(GenericReactions.twoEmoji))
            {
                StatValue = 2;
            }
            if (reaction.Emote.IsSameAs(GenericReactions.threeEmoji))
            {
                StatValue = 3;
            }
            if (reaction.Emote.IsSameAs(GenericReactions.fourEmoji))
            {
                StatValue = 4;
            }
            if (reaction.Emote.IsSameAs(GenericReactions.fiveEmoji))
            {
                StatValue = 5;
            }

            var stats = Array.ConvertAll(embed.Description.Split(','), int.Parse);

            string nextStat    = string.Empty;
            var    activeField = embed.Fields.First(embed => embed.Name == PlayerResources.ActiveStat);

            if (activeField.Value == PlayerResources.Edge)
            {
                stats[0] = StatValue; nextStat = PlayerResources.Heart;
            }
            if (activeField.Value == PlayerResources.Heart)
            {
                stats[1] = StatValue; nextStat = PlayerResources.Iron;
            }
            if (activeField.Value == PlayerResources.Iron)
            {
                stats[2] = StatValue; nextStat = PlayerResources.Shadow;
            }
            if (activeField.Value == PlayerResources.Shadow)
            {
                stats[3] = StatValue; nextStat = PlayerResources.Wits;
            }

            if (activeField.Value == PlayerResources.Wits)
            {
                stats[4] = StatValue;
                var player = new Player
                {
                    Edge   = stats[0],
                    Heart  = stats[1],
                    Iron   = stats[2],
                    Shadow = stats[3],
                    Wits   = stats[4],
                    Name   = embed.Author.Value.Name,
                };

                await message.ModifyAsync(msg => msg.Embed = player.GetEmbedBuilder().Build()).ConfigureAwait(false);

                Emoji[] playerCardControlEmojis = new Emoji[] { upEmoji, downEmoji, healthEmoji, spiritEmoji, supplyEmoji, momentumEmoji, burnEmoji };

                await Task.Run(async() =>
                {
                    await message.RemoveAllReactionsAsync();
                    await message.AddReactionsAsync(playerCardControlEmojis);
                }).ConfigureAwait(false);

                return;
            }

            var newHelper = embed.ToEmbedBuilder().WithDescription(String.Join(',', stats));

            newHelper.Fields.RemoveAll(fld => fld.Name == activeField.Name);
            newHelper.AddField(PlayerResources.ActiveStat, nextStat);

            await message.ModifyAsync(msg => msg.Embed = newHelper.Build()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);
        }
        public static Task Nav_Template_Layout_P4AU_Dual_Character(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "↩️")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Main(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Dual = "Normal";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Dual_Character_Default_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Dual = "Navigator";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Dual_Character_Navigator_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Dual = "Television";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Dual_Character_Default_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Four
            else if (reaction.Emote.Name == "\u0034\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Dual = "Phone Call";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Dual_Character_Caller_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
        public static Task Nav_Template_Layout_P4AU_Caller_Location(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "💠")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Main(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Dojima Residence, Bedroom";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Yosuke’s Room";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Chie’s Room";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Four
            else if (reaction.Emote.Name == "\u0034\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Airport";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Five
            else if (reaction.Emote.Name == "\u0035\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Amagi Inn, Kitchen";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Six
            else if (reaction.Emote.Name == "\u0036\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Limousine";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Seven
            else if (reaction.Emote.Name == "\u0037\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Junes Food Court";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Eight
            else if (reaction.Emote.Name == "\u0038\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Junes TV Department";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Nine
            else if (reaction.Emote.Name == "\u0039\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Phone_BG = "Hotel";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Caller_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
Пример #8
0
        public static async Task <string> MysteryBox2(SocketGuild guild, SocketReaction reaction)
        {
            var UserAccount = UserAccounts.GetAccount(reaction.User.Value);

            string reward = "";
            string coin   = Messages.coin;

            Random rand1        = new Random();
            int    RandomNumber = rand1.Next(0, 100);

            if (RandomNumber <= 25)
            {// Nothing
                reward = "0";
                return(reward);
            }
            if (RandomNumber <= 50)
            {// Money 500 to 2000
                Random randS  = new Random();
                int    result = randS.Next(500, 2001);
                reward = $"{result.ToString()}{coin}";

                UserAccount.MoneyWallet += (ulong)result;
                return(reward);
            }
            if (RandomNumber <= 65)
            { // Money 2000 to 3500
                Random randB  = new Random();
                int    result = randB.Next(2000, 3501);
                reward = $"{result.ToString()}{coin}";

                UserAccount.MoneyWallet += (ulong)result;
                return(reward);
            }
            if (RandomNumber <= 70)
            { // Vip Role
                reward = $"RANGA VIP {Messages.vip}";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "VIP");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 80)
            { // Nick Role
                reward = "ZMIANĘ NICKU 🏷️";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🏷️");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 85)
            { // Aki Role
                reward = "DOSTĘP DO AKINATORA 👳";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "👳");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 90)
            { // Music Role
                reward = "DOSTĘP DO MUZYKI 🎵";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🎵");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 91)
            { // Animal: fish
                reward = "RYBĘ 🐟";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐟");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 92)
            { // Animal: chamster
                reward = "CHOMIKA 🐹";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐹");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 93)
            { // Animal: dog
                reward = "PIESKA 🐶";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐶");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 94)
            { // Animal: cat
                reward = "KOTKA 🐱";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐱");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 95)
            { // Animal: horse
                reward = "KONIA 🐴";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐴");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 97)
            { // Vehicle: bike
                reward = "ROWER 🚲";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🚲");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 99)
            { // Vehicle: car
                reward = "SAMOCHÓD 🚗";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🚗");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 100)
            { // Vehicle: sailboat
                reward = "ŻAGLÓWKĘ ⛵";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "⛵");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }

            return(reward);
        }
Пример #9
0
        public static async Task <string> MysteryBox3(SocketGuild guild, SocketReaction reaction)
        {
            var UserAccount = UserAccounts.GetAccount(reaction.User.Value);

            string reward = "";
            string coin   = Messages.coin;

            Random rand1        = new Random();
            int    RandomNumber = rand1.Next(0, 100);

            if (RandomNumber <= 25)
            {// Nothing
                reward = "0";
                return(reward);
            }
            if (RandomNumber <= 50)
            {// Money 1500 to 3000
                Random randS  = new Random();
                int    result = randS.Next(1500, 3001);
                reward = $"{result.ToString()}{coin}";

                UserAccount.MoneyWallet += (ulong)result;
                return(reward);
            }
            if (RandomNumber <= 65)
            { // Money 3000 to 5000
                Random randB  = new Random();
                int    result = randB.Next(3000, 5001);
                reward = $"{result.ToString()}{coin}";

                UserAccount.MoneyWallet += (ulong)result;
                return(reward);
            }
            if (RandomNumber <= 75)
            { // Vip Role
                reward = $"RANGA VIP {Messages.vip}";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "VIP");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 81)
            { // Svip role
                reward = $"RANGA SVIP {Messages.svip}";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "SVIP");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 86)
            { // Music Role
                reward = "DOSTĘP DO MUZYKI 🎵";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🎵");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 91)
            { // Aki Role
                reward = "DOSTĘP DO AKINATORA 👳";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "👳");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 92)
            { // Animal: dog
                reward = "PIESKA 🐶";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐶");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 93)
            { // Animal: cat
                reward = "KOTKA 🐱";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐱");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 94)
            { // Animal: horse
                reward = "KONIA 🐴";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐴");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 95)
            { // Animal: penguin
                reward = "PINGWINKA 🐧";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐧");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 96)
            { // Animal: panda
                reward = "PANDĘ 🐼";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🐼");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 97)
            { // Vehicle: car
                reward = "SAMOCHÓD 🚗";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🚗");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 98)
            { // Vehicle: sailboat
                reward = "ŻAGLÓWKĘ ⛵";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "⛵");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 99)
            { // Vehicle: train
                reward = "POCIĄG 🚂";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🚂");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }
            if (RandomNumber <= 100)
            { // Vehicle: motorbike
                reward = "MOTOCYKL 🏍️";

                var RoleToAdd = guild.Roles.FirstOrDefault(x => x.Name == "🏍️");
                var CastUser  = (SocketGuildUser)reaction.User;
                await CastUser.AddRoleAsync(RoleToAdd);

                return(reward);
            }

            return(reward);
        }
Пример #10
0
        protected override async Task ProcessReaction(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            try
            {
                if (reaction.User.Value.IsBot)
                {
                    return;
                }
                if (channel.Id != Teams[Team.A].teamChannel.Id && channel.Id != Teams[Team.B].teamChannel.Id)
                {
                    return;
                }
                if (reaction.Emote.Name == "Fight_A")
                {
                    _ = AddPlayer(reaction, Team.A);
                    return;
                }
                if (reaction.Emote.Name == "Fight_B")
                {
                    _ = AddPlayer(reaction, Team.B);
                    return;
                }
                else if (reaction.Emote.Name == "Battle")
                {
                    _ = StartBattle();
                    return;
                }

                Teams.Values.ToList().ForEach(async V =>
                {
                    var StatusMessage  = V.StatusMessage;
                    var PlayerMessages = V.PlayerMessages;
                    var EnemyMessage   = V.EnemyMessage;
                    var SummonsMessage = V.SummonsMessage;
                    if (channel.Id != V.teamChannel.Id)
                    {
                        return;
                    }
                    IUserMessage c = null;
                    if (StatusMessage.Id == reaction.MessageId)
                    {
                        c = StatusMessage;
                    }
                    if (EnemyMessage.Id == reaction.MessageId)
                    {
                        c = EnemyMessage;
                    }
                    if (SummonsMessage.Id == reaction.MessageId)
                    {
                        c = SummonsMessage;
                    }
                    if (PlayerMessages.Keys.Any(k => k.Id == reaction.MessageId))
                    {
                        c = PlayerMessages.Keys.Where(k => k.Id == reaction.MessageId).First();
                    }

                    if (c == null)
                    {
                        c = (IUserMessage)await channel.GetMessageAsync(reaction.MessageId);
                        _ = c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        Console.WriteLine("No matching Message for User found.");
                        return;
                    }

                    if (!Battle.isActive)
                    {
                        _ = c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        Console.WriteLine("Battle not active.");
                        return;
                    }

                    if (Battle.turnActive)
                    {
                        _ = c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        Console.WriteLine("Not so fast");
                        return;
                    }

                    if (reaction.Emote.Name == "🔄")
                    {
                        await c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        autoTurn.Stop();
                        Task.WaitAll(PlayerMessages.Select(m => m.Key.RemoveAllReactionsAsync()).Append(EnemyMessage.RemoveAllReactionsAsync()).ToArray());

                        _ = WriteBattleInit();
                        autoTurn.Start();
                        return;
                    }

                    if (reaction.Emote.Name == "⏸")
                    {
                        autoTurn.Stop();
                        return;
                    }

                    if (reaction.Emote.Name == "▶")
                    {
                        autoTurn.Start();
                        return;
                    }

                    if (reaction.Emote.Name == "⏩")
                    {
                        _ = ProcessTurn(true);
                        return;
                    }

                    var curPlayer = PlayerMessages.Values.Where(p => p.avatar.ID == reaction.User.Value.Id).FirstOrDefault();
                    if (curPlayer == null)
                    {
                        _ = c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        Console.WriteLine("Player not in this room.");
                        return;
                    }
                    var correctID = PlayerMessages.Keys.Where(key => PlayerMessages[key].avatar.ID == curPlayer.avatar.ID).First().Id;

                    if (!numberEmotes.Contains(reaction.Emote.Name))
                    {
                        if (reaction.MessageId != EnemyMessage.Id && reaction.MessageId != correctID)
                        {
                        }
                    }

                    if (!curPlayer.Select(reaction.Emote))
                    {
                        _ = c.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                        Console.WriteLine("Couldn't select that move.");
                        return;
                    }
                    reactions.Add(reaction);
                });

                _ = ProcessTurn(forced: false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Colosso Turn Processing Error: " + e.Message);
                File.WriteAllText($"Logs/Crashes/Error_{DateTime.Now.Date}.log", e.Message);
            }
            await Task.CompletedTask;
        }
Пример #11
0
        internal static async Task HandleBanroyaleReactionAsync(Cacheable <IUserMessage, ulong> msg, Cacheable <IMessageChannel, ulong> ch, SocketReaction reaction)
        {
            if (!BanroyaleMessageDict.TryGetValue(reaction.MessageId, out var br))
            {
                return;
            }
            if (br.Emote.Id != ((Emote)reaction.Emote).Id)
            {
                return;
            }

            var usersReac = (await br.Message.GetReactionUsersAsync(br.Emote, 100).FlattenAsync()).Select(x => x.Id).ToHashSet();
            var users     = br.Role.Members.Where(x => !usersReac.Contains(x.Id)).ToList();

            if (br.KickLast >= users.Count())
            {
                BanroyaleMessageDict.Remove(br.Message.Id);
                br.Waiting = false;
                await LostUsers(br, users);
            }
        }
        public static Task Nav_Resolution_Scaling_P3F_Output_Resolution(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "↩️")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Resolution_Scaling_P3F_Menu.Resolution_Scaling_P3F_Main(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P3F_Resolution = "640 × 448";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Resolution_Scaling_P3F_Menu.Resolution_Scaling_P3F_Output_Resolution_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P3F_Resolution = "640 × 480";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Resolution_Scaling_P3F_Menu.Resolution_Scaling_P3F_Output_Resolution_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P3F_Resolution = "1440 × 1080";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Resolution_Scaling_P3F_Menu.Resolution_Scaling_P3F_Output_Resolution_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
Пример #13
0
        private async Task ShipReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var starshipHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(StarShipResources.StarshipHelperTitle) ?? false);

            if (starshipHelperEmbed != null)
            {
                var region = StarforgedUtilites.SpaceRegionFromEmote(reaction.Emote.Name);
                if (region == SpaceRegion.None)
                {
                    return;
                }

                string name = starshipHelperEmbed.Fields.FirstOrDefault(fld => fld.Name == StarShipResources.StarshipName).Value ?? string.Empty;

                Starship newShip = Starship.GenerateShip(Services, region, name);
                Task.WaitAll(message.RemoveAllReactionsAsync());

                await message.ModifyAsync(msg =>
                {
                    msg.Content = string.Empty;
                    msg.Embed   = newShip.GetEmbedBuilder().Build();
                }).ConfigureAwait(false);

                await message.AddReactionAsync(missionEmoji).ConfigureAwait(false);

                return;
            }

            var shipEmbed = message.Embeds.FirstOrDefault(embed => embed?.Description?.Contains(StarShipResources.Starship, StringComparison.OrdinalIgnoreCase) ?? false);

            if (shipEmbed == null)
            {
                return;
            }

            Starship ship = Starship.FromEmbed(Services, shipEmbed);

            if (reaction.Emote.Name == missionEmoji.Name)
            {
                ship.MissionRevealed = true;
                await message.RemoveReactionAsync(reaction.Emote, message.Author).ConfigureAwait(false);
            }

            await message.ModifyAsync(msg => msg.Embed = ship.GetEmbedBuilder().Build()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            return;
        }
Пример #14
0
 private Task AddedReaction(Cacheable <IUserMessage, ulong> cashe, ISocketMessageChannel channel, SocketReaction reaction)
 {
     if (!reaction.User.Value.IsBot)
     {
         if (Modules.Global.HelpHandler.Item1 != null && reaction.MessageId == Modules.Global.HelpHandler.Item1.Id)
         {
             if (reaction.Emote.Name == "◀" || reaction.Emote.Name == "▶")
             {
                 Modules.Global.HelpHandler.Item1.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                 Modules.Ping.Turn(reaction.Emote.Name);
             }
         }
     }
     return(Task.CompletedTask);
 }
Пример #15
0
 private async Task _onReactionRemovedAsync(Cacheable <IUserMessage, ulong> cached, ISocketMessageChannel channel, SocketReaction reaction)
 {
     await Bot.DiscordUtils.HandlePaginatedMessageReactionAsync(cached, channel, reaction, false);
 }
Пример #16
0
        private Task ReactionAdded(Cacheable <IUserMessage, ulong> cacheUserMessage, ISocketMessageChannel socketMessageChannel, SocketReaction socketReaction)
        {
            _ = Task.Run(async() =>
            {
                // Get or download the user cache from the Server.
                IUserMessage userMessage = await cacheUserMessage.GetOrDownloadAsync();

                if (socketReaction.User.GetValueOrDefault() is not SocketGuildUser currentUser)
                {
                    currentUser = _client.GetUser(socketReaction.UserId) as SocketGuildUser;
                }

                // Debug Mode:
                if (socketReaction.Channel.Id.Equals(761687188341522492))
                {
                    _logger.ConsoleLog(new LogMessage(LogSeverity.Debug, "Debugging", "Working as intentional."));
                    return;
                }

                // If the socket reaction, is from any of the filtered channels.
                if (_clanApplicationChannels.Contains(socketReaction.Channel.Id))
                {
                    // If the user has any roles from the filter.
                    if (currentUser.Roles.Any(r => r.Id.Equals(414618518554673152)))
                    {
                        string message   = $"Leadership assigned reaction <{socketReaction.Emote.Name}> to message.";
                        string createdBy = currentUser.Id.ToString();

                        await _logger.LogAsync(new LogModel(LoggingSeverity.Info, "Reaction Added", message, createdBy, DateTime.UtcNow));

                        return;
                    }

                    // Process a new clan application.
                    // Old Caller.
                    //await _clanApplication.ProcessClanApplicationAsync(currentReaction, currentUser);

                    // New Caller
                    await _clanApplication.ApplyToClanAsync(socketReaction, currentUser);

                    // Remove Reaction after process.
                    await userMessage.RemoveReactionAsync(socketReaction.Emote, socketReaction.UserId);
                }
            });

            return(Task.CompletedTask);
        }
        public static Task Nav_Template_Layout_P4AU_Control_Panel(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "↩️")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Main(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Panel = "PlayStation®️ 3";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Control_Panel_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Panel = "Xbox 360";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Control_Panel_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Panel = "None";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Control_Panel_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
Пример #18
0
        private async Task Client_ReactionAdded(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.User.IsSpecified)
            {
                var user = reaction.User.Value;
                var poll = _activePolls.FirstOrDefault(p => p.Message.Id == message.Id);
                if (poll != null)
                {
                    var userMessage = await message.GetOrDownloadAsync();

                    // if the user used an emote that wasn't allowed
                    if (!poll.AllowedEmoji.Exists(emote => emote.Name == reaction.Emote.Name))
                    {
                        // remove the emote
                        await userMessage.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                    }
                    else
                    {
                        // don't remove multiple votes from the bot
                        if (user.Id != _discordSocketClient.CurrentUser.Id)
                        {
                            // loop through all the emotes used
                            foreach (var emote in userMessage.Reactions.Keys.Where(r => r != reaction.Emote))
                            {
                                if (emote.Name != reaction.Emote.Name)
                                {
                                    await userMessage.RemoveReactionAsync(emote, user);
                                }
                            }
                        }
                    }
                }
            }
        }
        public static Task Nav_Template_Layout_P4AU_Navigator_Location(SocketReaction reaction, MenuIdStructure menuSession)
        {
            // Search for an item list that corresponds to the user's ID.
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == reaction.UserId);

            if (reaction.Emote.Name == "💠")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Main(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Perform various actions based on what type of reaction was given to the message.
            // Previous Page
            else if (reaction.Emote.Name == "◀️")
            {
                try
                {
                    // Decrease the item index by the maximum number of items that should be displayed to the user at once.
                    itemSession.ItemIndexBase -= itemSession.MaxItemsDisplayed;

                    // Decrease the page counter by one.
                    itemSession.CurrentPage--;

                    // Stop the timeout timer associated with the menu.
                    menuSession.MenuTimer.Stop();

                    // Go to a new menu.
                    _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location(menuSession.User, menuSession.MenuMessage);
                    return(Task.CompletedTask);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            // Next Page
            else if (reaction.Emote.Name == "▶️")
            {
                try
                {
                    // Increase the item index by the maximum number of items that should be displayed to the user at once.
                    itemSession.ItemIndexBase += itemSession.MaxItemsDisplayed;

                    // Increase the page counter by one.
                    itemSession.CurrentPage++;

                    // Stop the timeout timer associated with the menu.
                    menuSession.MenuTimer.Stop();

                    // Go to a new menu.
                    _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location(menuSession.User, menuSession.MenuMessage);
                    return(Task.CompletedTask);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 1;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 2;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 3;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Four
            else if (reaction.Emote.Name == "\u0034\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 4;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Five
            else if (reaction.Emote.Name == "\u0035\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 5;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // Keycap Six
            else if (reaction.Emote.Name == "\u0036\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4AU_TS_Nav_BG = itemSession.ItemIndexBase + 6;

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

                // Go to a new menu.
                _ = Template_Layout_P4AU_Menu.Template_Layout_P4AU_Navigator_Location_Confirm(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
Пример #20
0
        private async Task AddUserToRole(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (message.Id != ReactionMessageID)
            {
                return;
            }

            var reactionAuthor = Guild.GetUser(reaction.UserId);

            if (reactionAuthor.Roles.Any(r => r.Id == AnimeRoleID))
            {
                return;
            }

            await reactionAuthor.AddRoleAsync(Guild.GetRole(AnimeRoleID));

            Log($"Added {reactionAuthor.Username} to the anime role.");
        }
Пример #21
0
        private async Task ReactionHandler(Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            try
            {
                await verificationHandler.CheckVerification(arg1, arg2, arg3);
                await checkSub(arg1, arg2, arg3);

                await helpMessageHandler.HandleHelpMessage(arg1, arg2, arg3);
            }
            catch (Exception ex)
            {
                Global.ConsoleLog($"Reaction handler error: {ex.Message} \n {ex.StackTrace}", ConsoleColor.Red);
                Global.SendExeption(ex);
            }
        }
Пример #22
0
        private async Task RemoveUserFromRole(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (message.Id != ReactionMessageID)
            {
                return;
            }

            var reactionAuthor = Guild.GetUser(reaction.UserId);

            if (reactionAuthor.Roles.All(r => r.Id != AnimeRoleID))
            {
                return;
            }

            await reactionAuthor.RemoveRoleAsync(Guild.GetRole(AnimeRoleID));

            Log($"Removed {reactionAuthor.Username} from the anime role.");
        }
Пример #23
0
        private async Task BurnMomentumReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            if (!IsPlayerCardPost(message))
            {
                return;
            }

            var cs = await ChannelSettings.GetChannelSettingsAsync(channel.Id);

            var player           = new Player().WithChannelSettings(cs).PopulateFromEmbed(message.Embeds.First());
            int startingMomentum = player.Momentum;

            player.Momentum = 2 - player.Debilities;

            await message.ModifyAsync(msg => msg.Embed = player.GetEmbedBuilder().Build()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            await message.ReplyAsync(String.Format(PlayerResources.BurnMomentumMessage, player.Name, startingMomentum));
        }
Пример #24
0
        public async void ProcessTheRemovedReaction(Cacheable <IUserMessage, ulong> messageWithReaction, ISocketMessageChannel channel, SocketReaction reaction)
        {
            try
            {
                await Task.Run(async() =>
                {
                    if (reaction.UserId == ClientControlManager.MainBot.Client.CurrentUser.Id)
                    {
                        return;
                    }

                    var user         = reaction.User.Value;
                    var message      = await messageWithReaction.DownloadAsync();
                    var messageTitle = message.Embeds.First().Title;

                    if (!(message.Author.Id == ClientControlManager.MainBot.Client.CurrentUser.Id) || (message.Embeds.Count == 0))
                    {
                        return;
                    }
                    if (!(channel is IDMChannel))
                    {
                        var channelCategory = await((IGuildChannel)channel).GetCategoryAsync();
                        if (channelCategory == null)
                        {
                            return;
                        }
                        // для рейтингового листа
                        if (channelCategory.Id == (ulong)CategoryIds.Rating_Lists)
                        {
                            return;
                        }
                        // для остальных категорий
                        switch (MessageTitles.GetType(messageTitle))
                        {
                        case TitleType.WantPlay:
                            if (reaction.Emote.Name == "✅")
                            {
                                await Task.Run(() => WantPlayMessageCommands.RemoveUserAcceptedAsync(message, user));
                            }
                            break;

                        case TitleType.VipGiveaway:
                            if (!DataControlManager.ParticipantsOfTheGiveaway.Value.ContainsKey(GiveawayType.VIP))
                            {
                                break;
                            }
                            DataControlManager.ParticipantsOfTheGiveaway.Value[GiveawayType.VIP].Remove(user.Id);
                            await DataControlManager.ParticipantsOfTheGiveaway.SaveAsync();
                            break;

                        case TitleType.ManageRole:
                            switch (reaction.Emote.Name)
                            {
                            case "🎵": await Task.Run(() => CommandControlManager.RoleManagement.RemoveAsync(reaction.User.Value, (ulong)RoleIds.DJ)); break;

                            case "🈹": await Task.Run(() => CommandControlManager.RoleManagement.RemoveAsync(reaction.User.Value, (ulong)RoleIds.Anime_Fun)); break;
                            }
                            break;
                        }
                    }
                    //Для лички
                    else
                    {
                    }
                });
            }
            catch (Exception ex)
            {
                new ExceptionLogger().Log(ex, "Ошибка при обработке удалённой реакции");
            }
        }
Пример #25
0
        private async Task ResourceChangeHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            if (!IsPlayerCardPost(message))
            {
                return;
            }
            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            var healthActive   = message.GetReactionUsersAsync(healthEmoji, 5).AnyAsync(col => col.Any(u => u.Id == user.Id));
            var spiritActive   = message.GetReactionUsersAsync(spiritEmoji, 5).AnyAsync(col => col.Any(u => u.Id == user.Id));
            var supplyActive   = message.GetReactionUsersAsync(supplyEmoji, 5).AnyAsync(col => col.Any(u => u.Id == user.Id));
            var momentumActive = message.GetReactionUsersAsync(momentumEmoji, 5).AnyAsync(col => col.Any(u => u.Id == user.Id));

            Task[] tasks = new Task[] { healthActive.AsTask(), supplyActive.AsTask(), spiritActive.AsTask(), momentumActive.AsTask() };

            await Task.WhenAll(tasks);

            List <bool> activeResources = new List <bool> {
                healthActive.Result, supplyActive.Result, spiritActive.Result, momentumActive.Result
            };

            if (activeResources.Count(b => b) > 1)
            {
                var existingEmbed = message.Embeds.First().ToEmbedBuilder();
                existingEmbed.WithFooter(PlayerResources.TooManyStatsActive);

                await message.ModifyAsync(msg => msg.Embed = existingEmbed.Build()).ConfigureAwait(false);

                return;
            }

            int direction = 0;

            if (reaction.Emote.IsSameAs(upEmoji))
            {
                direction = 1;
            }
            if (reaction.Emote.IsSameAs(downEmoji))
            {
                direction = -1;
            }

            var cs = await ChannelSettings.GetChannelSettingsAsync(channel.Id);

            var player = new Player().WithChannelSettings(cs).PopulateFromEmbed(message.Embeds.First());

            if (healthActive.Result)
            {
                player.Health += direction;
            }
            if (supplyActive.Result)
            {
                player.Supply += direction;
            }
            if (spiritActive.Result)
            {
                player.Spirit += direction;
            }
            if (momentumActive.Result)
            {
                player.Momentum += direction;
            }

            await message.ModifyAsync(msg => msg.Embed = player.GetEmbedBuilder().Build());
        }
Пример #26
0
        public async void ProcessTheAddedReaction(Cacheable <IUserMessage, ulong> messageWithReaction, ISocketMessageChannel channel, SocketReaction reaction)
        {
            try
            {
                await Task.Run(async() =>
                {
                    if (reaction.UserId == ClientControlManager.MainBot.Client.CurrentUser.Id)
                    {
                        return;
                    }

                    var user         = reaction.User.Value;
                    var message      = await messageWithReaction.DownloadAsync();
                    var messageTitle = message.Embeds.First().Title;

                    if ((message.Author.Id != ClientControlManager.MainBot.Client.CurrentUser.Id) || (message.Embeds.Count == 0))
                    {
                        return;
                    }
                    if (!(channel is IDMChannel))
                    {
                        var channelCategory = await((IGuildChannel)channel).GetCategoryAsync();
                        if (channelCategory == null)
                        {
                            return;
                        }
                        //для рейтингового листа
                        if (channelCategory.Id == (ulong)CategoryIds.Rating_Lists)
                        {
                            await message.RemoveReactionAsync(reaction.Emote, user);
                            string objName = message.Embeds.First().Title;

                            switch (reaction.Emote.Name)
                            {
                            case "💙": await CommandControlManager.RatingList.ChangeRatingAsync(user.Id, channel, objName, Evaluation.Like); break;

                            case "❌": await CommandControlManager.RatingList.ChangeRatingAsync(user.Id, channel, objName, Evaluation.Dislike); break;

                            case "🎮":
                                await Task.Run(() => CommandControlManager.WantPlayMessage.SendAsync(user, objName, message.Embeds.First().Thumbnail?.Url, message.Embeds.First().Url)); break;
                            }
                        }
                        else
                        {
                            //для остальных категорий

                            if ((messageTitle == null) || (messageTitle == ""))
                            {
                                return;
                            }
                            switch (MessageTitles.GetType(messageTitle))
                            {
                            case TitleType.WantPlay:
                                switch (reaction.Emote.Name)
                                {
                                case "✅": await Task.Run(() => WantPlayMessageCommands.AddUserAcceptedAsync(message, user)); break;

                                    /*case "📩":
                                     *  await message.RemoveReactionAsync(reaction.Emote, user);
                                     *  await Task.Run(() => WantPlayMessageCommands.SendOptionsOfSubscriptionAsync(message, user)); break;*/
                                }
                                break;

                            case TitleType.VipGiveaway:
                                if (!DataControlManager.ParticipantsOfTheGiveaway.Value.ContainsKey(GiveawayType.VIP) ||
                                    (DataControlManager.ParticipantsOfTheGiveaway.Value[GiveawayType.VIP].Contains(user.Id)))
                                {
                                    break;
                                }
                                DataControlManager.ParticipantsOfTheGiveaway.Value[GiveawayType.VIP].Add(user.Id);
                                await DataControlManager.ParticipantsOfTheGiveaway.SaveAsync();
                                break;

                            case TitleType.ManageRole:
                                switch (reaction.Emote.Name)
                                {
                                case "🎵": if (DataControlManager.UserProfiles.Value[reaction.UserId].Level > 8)
                                    {
                                        await Task.Run(() => CommandControlManager.RoleManagement.GetAsync(reaction.User.Value, (ulong)RoleIds.DJ));
                                    }
                                    break;

                                case "🈹": if (DataControlManager.UserProfiles.Value[reaction.UserId].Level > 5)
                                    {
                                        await Task.Run(() => CommandControlManager.RoleManagement.GetAsync(reaction.User.Value, (ulong)RoleIds.Anime_Fun));
                                    }
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    //Для лички
                    else
                    {
                        switch (MessageTitles.GetType(messageTitle))
                        {
                        case TitleType.SubscriptionManager:
                            switch (reaction.Emote.Name)
                            {
                            case "1⃣": await Task.Run(() => WantPlayMessageCommands.AddUserSubscriptionAsync(message, user, 1)); break;

                            case "2⃣": await Task.Run(() => WantPlayMessageCommands.AddUserSubscriptionAsync(message, user, 2)); break;

                            case "3⃣": await Task.Run(() => WantPlayMessageCommands.AddUserSubscriptionAsync(message, user, 3)); break;

                            case "4⃣": await Task.Run(() => WantPlayMessageCommands.AddUserSubscriptionAsync(message, user, 4)); break;

                            case "5⃣": await Task.Run(() => WantPlayMessageCommands.RemoveUserSubscriptionAsync(message, user, 5)); break;

                            case "6⃣": await Task.Run(() => WantPlayMessageCommands.RemoveUserSubscriptionAsync(message, user, 6)); break;

                            case "7⃣": await Task.Run(() => WantPlayMessageCommands.RemoveUserSubscriptionAsync(message, user, 7)); break;

                            case "8⃣": await Task.Run(() => WantPlayMessageCommands.RemoveUserSubscriptionAsync(message, user, 8)); break;
                            }
                            break;
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                new ExceptionLogger().Log(ex, "Ошибка при обработке добавленной реакции");
            }
        }
Пример #27
0
 public async Task OnReactionRemoved(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel chan, SocketReaction reaction)
 => await this.OnReaction(cache, chan, reaction);
Пример #28
0
        public async Task <bool> HandleCallbackAsync(SocketReaction reaction)
        {
            var emote = reaction.Emote;

            if (emote.Equals(options.First))
            {
                title = 1;
                page  = 1;
            }
            else if (emote.Equals(options.Next))
            {
                if (page >= pages)
                {
                    return(false);
                }
                ++page;
                ++title;
            }
            else if (emote.Equals(options.Back))
            {
                if (page <= 1)
                {
                    return(false);
                }
                --page;
                --title;
            }
            else if (emote.Equals(options.Last))
            {
                page = pages;
            }
            else if (emote.Equals(options.Stop))
            {
                await Message.DeleteAsync().ConfigureAwait(false);

                return(true);
            }
            else if (emote.Equals(options.Jump))
            {
                _ = Task.Run(async() =>
                {
                    var criteria = new Criteria <SocketMessage>()
                                   .AddCriterion(new EnsureSourceChannelCriterion())
                                   .AddCriterion(new EnsureFromUserCriterion(reaction.UserId))
                                   .AddCriterion(new EnsureIsIntegerCriterion());
                    var response = await Interactive.NextMessageAsync(Context, criteria, TimeSpan.FromSeconds(15));
                    var request  = int.Parse(response.Content);
                    if (request < 1 || request > pages)
                    {
                        _ = response.DeleteAsync().ConfigureAwait(false);
                        await Interactive.ReplyAndDeleteAsync(Context, options.Stop.Name);
                        return;
                    }
                    page = request;
                    _    = response.DeleteAsync().ConfigureAwait(false);
                    await RenderAsync().ConfigureAwait(false);
                });
            }
            else if (emote.Equals(options.Info))
            {
                await Interactive.ReplyAndDeleteAsync(Context, options.InformationText, timeout : options.InfoTimeout);

                return(false);
            }
            _ = Message.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
            await RenderAsync().ConfigureAwait(false);

            return(false);
        }
Пример #29
0
 private async Task ReactionRemoved(Cacheable <IUserMessage, ulong> _, ISocketMessageChannel __, SocketReaction reaction)
 => await ReactionManipulated(reaction, ReactionAction.Remove);
Пример #30
0
        private async Task OnReactionAdded_TestLocation(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.MessageId == Global.LocationMessageIdToTrack)
            {
                string[]          location_role_arr = { "North America", "South America", "Europe", "Asia", "Africa", "Australia" };
                string[]          location_emot_arr = { "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣" };
                List <SocketRole> UserRolesRemoval  = new List <SocketRole>();

                for (int i = 0; i < 6; i++)
                {
                    if (reaction.Emote.Name == location_emot_arr[i])
                    {
                        SocketGuildUser Current_User = (SocketGuildUser)reaction.User;
                        if (null == Current_User)
                        {
                            return;
                        }

                        SocketRole Role_To_Add = Current_User.Guild.Roles.FirstOrDefault(x => x.Name.Contains(location_role_arr[i])) as SocketRole;
                        if (null == Role_To_Add)
                        {
                            return;
                        }


                        /* Add all of our current location roles to the list */
                        foreach (SocketRole myRole in Current_User.Roles.ToArray())
                        {
                            if (location_role_arr.Contains(myRole.Name))
                            {
                                UserRolesRemoval.Add(myRole);
                            }
                        }

                        /* Throw them all in the trash */
                        if (UserRolesRemoval.Count > 0)
                        {
                            await Current_User.RemoveRolesAsync(UserRolesRemoval);
                        }

                        await Current_User.AddRoleAsync(Role_To_Add);

                        break;
                    }
                }
            }
        }