Exemplo n.º 1
0
        public async Task ListSuggestedMovies([Summary("The page number to start on.")] int number = 1)
        {
            try {
                if (serversAndSuggestionsEmbeds == null)
                {
                    serversAndSuggestionsEmbeds = new Dictionary <ulong, ShowMovieSuggestions>();
                }
                if (!serversAndSuggestionsEmbeds.ContainsKey(Context.Guild.Id))
                {
                    ShowMovieSuggestions sugg = new ShowMovieSuggestions(Context.Guild, Context.Channel, false);
                    sugg.pageNumber = number - 1;
                    serversAndSuggestionsEmbeds.Add(Context.Guild.Id, sugg);

                    RestUserMessage mess = await Context.Channel.SendMessageAsync("See Suggested Movies", embed : sugg.MakeEmbed()).ConfigureAwait(false);

                    Emoji[] votes = new Emoji[4];
                    votes[0] = MojiCommand.CommandMoji[3];
                    votes[1] = MojiCommand.CommandMoji[4];
                    votes[2] = MojiCommand.CommandMoji[5];
                    votes[3] = MojiCommand.CommandMoji[6];
                    await mess.AddReactionsAsync(votes);

                    sugg.suggestionsMessage = mess;
                }
            } catch (DataException ex) {
                await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A data related exception was raised.", ex));

                await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:");
            } catch (Exception ex) {
                await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A general exception was raised.", ex));

                await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:");
            }
        }
Exemplo n.º 2
0
        private async Task CheckNewSuggestion(SocketMessage arg)
        {
            if (!IsSuggestion(arg.Content))
            {
                return;
            }

            RestUserMessage restMessage = (RestUserMessage)await arg.Channel.GetMessageAsync(arg.Id);

            if (IsDuplicate(arg.Content))
            {
                await restMessage.Channel.SendMessageAsync("that has been suggested before and **any attempt to bypass a duplicate check will result in a channel ban**");

                return;
            }

            if (arg.Content.Length > 1024)
            {
                await restMessage.Channel.SendMessageAsync("A suggestion shouldn't exceed 1024 characters. Try not to group multiple suggestions into a single message.");
            }

            await restMessage.AddReactionsAsync(new IEmote[] { Upvote, Downvote });

            AddSuggestion((IUserMessage)arg, false);
            Save();
        }
Exemplo n.º 3
0
        public async Task RaidGuide([Summary("Tier of the raid boss.")] string tier)
        {
            short calcTier = Global.RAID_TIER_STRING.ContainsKey(tier) ? Global.RAID_TIER_STRING[tier] : Global.INVALID_RAID_TIER;
            Dictionary <int, List <string> > allBosses = Connections.Instance().GetFullBossList();
            List <string> potentials = calcTier == Global.INVALID_RAID_TIER || !allBosses.ContainsKey(calcTier) ? new List <string>() : allBosses[calcTier];
            string        fileName;

            if (potentials.Count > 1)
            {
                fileName = $"Egg{calcTier}.png";
                Connections.CopyFile(fileName);
                RestUserMessage selectMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildBossSelectEmbed(potentials, fileName));

                guideMessages.Add(selectMsg.Id, potentials);
                Connections.DeleteFile(fileName);
                selectMsg.AddReactionsAsync(Global.SELECTION_EMOJIS.Take(potentials.Count).ToArray());
            }
            else if (potentials.Count == 1)
            {
                Pokemon pkmn = Connections.Instance().GetPokemon(potentials.First());
                Connections.Instance().GetRaidBoss(ref pkmn);

                fileName = Connections.GetPokemonPicture(pkmn.Name);
                Connections.CopyFile(fileName);
                await Context.Channel.SendFileAsync(fileName, embed : BuildRaidGuideEmbed(pkmn, fileName));

                Connections.DeleteFile(fileName);
            }
            else
            {
                await ResponseMessage.SendErrorMessage(Context.Channel, "guide", $"No raid bosses found for tier {tier}");
            }
            RemoveOldRaids();
        }
Exemplo n.º 4
0
        public static async Task <GuildCreationInteractiveMessage> FromNewGuildAndMemberList(MinecraftGuild guild, List <SocketGuildUser> Members)
        {
            StringBuilder mentionString = new StringBuilder();

            foreach (SocketGuildUser member in Members)
            {
                guild.MemberIds.Add(member.Id);
                mentionString.Append(member.Mention);
                mentionString.Append(" ");
            }

            RestUserMessage message = await GuildChannelHelper.SendMessage(GuildChannelHelper.InteractiveMessagesChannelId, guild.DiscordColor, content : $"{mentionString}Please confirm ({UnicodeEmoteService.Checkmark}) or deny ({UnicodeEmoteService.Cross}) founding Membership in Guild `{guild.Name}` by reacting to this message! {Markdown.Mention_Role(SettingsModel.AdminRole)} Please choose to confirm ({UnicodeEmoteService.Checkmark}) or deny ({UnicodeEmoteService.Cross}) founding of this guild!", embedTitle : "Setting up Interactive Message - Stand By");

            if (message != null)
            {
                GuildCreationInteractiveMessage result = new GuildCreationInteractiveMessage(message as IUserMessage, guild);
                await message.AddReactionsAsync(new IEmote[] { UnicodeEmoteService.Checkmark, UnicodeEmoteService.Cross });

                await result.UpdateMessage(message as IUserMessage, Members[0].Guild);

                return(result);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public async Task Move([Summary("Get information about this move.")][Remainder] string move)
        {
            Move pkmnMove = Connections.Instance().GetMove(move);

            if (pkmnMove == null)
            {
                List <string> moveNames = Connections.Instance().SearchMove(move);

                string fileName = GENERIC_IMAGE;
                Connections.CopyFile(fileName);
                RestUserMessage dexMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildDexSelectEmbed(moveNames, fileName));

                dexSelectMessages.Add(dexMessage.Id, new DexSelectionMessage((int)DEX_MESSAGE_TYPES.MOVE_MESSAGE, moveNames));
                Connections.DeleteFile(fileName);
                dexMessage.AddReactionsAsync(Global.SELECTION_EMOJIS);
            }
            else
            {
                string fileName = GENERIC_IMAGE;
                Connections.CopyFile(fileName);
                await Context.Channel.SendFileAsync(fileName, embed : BuildMoveEmbed(pkmnMove, fileName));

                Connections.DeleteFile(fileName);
            }
        }
 /// <summary>
 /// Add reactions to the message
 /// </summary>
 /// <returns></returns>
 public static async Task AddReactionsAsync()
 {
     await QuoteConfirmationMessage.AddReactionsAsync(new Emoji[]
     {
         new Emoji("\U00002705"),
         new Emoji("\U0000274E")
     });
 }
Exemplo n.º 7
0
        public async Task ShowInventory(CommandMessage message)
        {
            // Shop items
            List <ShopItem> items = new List <ShopItem>();

            User user = await UserService.GetUser(message.Author);

            EmbedBuilder embed = new EmbedBuilder();

            embed.Title = message.Author.GetName() + "'s Inventory";
            embed.Color = Color.Blue;

            StringBuilder desc = new StringBuilder();

            if (user.Inventory.Count == 0)
            {
                desc.AppendLine("Nothing to show here. Visit our shop, _kupo!_");
            }
            else
            {
                // Load shop items
                items = await ShopItemDatabase.LoadAll(new Dictionary <string, object>()
                {
                    { "GuildId", message.Guild.Id },
                });

                // Restrict items to only held
                items = items.Where(x => user.Inventory.ContainsKey(x.Name)).ToList();

                foreach (KeyValuePair <string, int> item in user.Inventory)
                {
                    desc.AppendLine(item.Value + "x - " + item.Key);
                }
            }

            desc.AppendLine(Utils.Characters.Tab);

            embed.Description = desc.ToString();

            string prefix = CommandsService.GetPrefix(message.Guild.Id);

            embed.WithFooter("Use " + prefix + "shop to see items to buy. Select a reaction to redeem.");

            RestUserMessage userMessage = await message.Channel.SendMessageAsync(embed : embed.Build(), messageReference : message.MessageReference);

            // Add reacts
            await userMessage.AddReactionsAsync(items.Select(x => x.ReactionEmote).ToArray());

            // Handle reacts
            Program.DiscordClient.ReactionAdded += this.OnReactionAddedInventory;

            // Add to active windows
            this.activeInventoryWindows.Add(userMessage.Id, DateTime.Now);

            // Clear reacts
            _ = Task.Run(async() => await this.StopInventoryListener(userMessage));
        }
Exemplo n.º 8
0
        public static void CreateReactionCollector(this RestUserMessage userMessage, Action <ulong, IEmote, bool> onReactionChanged, params IEmote[] emotes)
        {
            ReactionCollector rCollector = new ReactionCollector()
            {
                ListeningEmotes   = emotes,
                MessageHandle     = userMessage,
                OnReactionChanged = onReactionChanged
            };

            userMessage.AddReactionsAsync(emotes);
            activeReactionCollectors.Add(userMessage.Id, rCollector);
        }
Exemplo n.º 9
0
        public async Task ServerSettings()
        {
            Options guildOptions = GlobalVars.GuildOptions.Single(x => x.GuildID == Context.Guild.Id).Options;

            EmbedBuilder builder = new EmbedBuilder();

            builder.Title = "Server settings";
            builder.AddField("\u0031\u20E3 Log Embedded messages", $"Currently:{(guildOptions.LogEmbeds ? "True" : "False")}");
            builder.AddField("\u0032\u20E3 Log Attached files", $"Currently:{(guildOptions.LogAttachments ? "True" : "False")}");

            RestUserMessage msg = await Context.Channel.SendMessageAsync(null, false, builder.Build());

            GlobalVars.AddSettingsTracker(msg, Context.Message.Author.Id);
            await msg.AddReactionsAsync(new Emoji[] { new Emoji("\u0031\u20E3"), new Emoji("\u0032\u20E3") });
        }
Exemplo n.º 10
0
        public async Task <Task> DisplayShop(CommandMessage message)
        {
            // Initial builder information
            EmbedBuilder embed = new EmbedBuilder();

            embed.Title = StoreTitle;
            embed.Color = Color.LightOrange;

            // Build store front
            StringBuilder builder = new StringBuilder();

            foreach (ShopItem item in shopItems)
            {
                // Add Item name
                builder.Append(item.ReactionEmote.GetString() + " " + "**" + item.Name + "**");

                // Add Cost
                builder.AppendLine(" - " + item.Cost + " " + KupoNut);

                // Add description
                builder.Append(Utils.Characters.Tab);
                builder.AppendLine("*" + item.Description + "*");
                builder.AppendLine();
            }

            builder.AppendLine(Utils.Characters.Tab);

            embed.Description = builder.ToString();

            User user = await UserService.GetUser(message.Author);

            embed.WithFooter("You have " + user.TotalKupoNutsCurrent + " Kupo Nuts to spend");

            RestUserMessage userMessage = await message.Channel.SendMessageAsync(embed : embed.Build(), messageReference : message.MessageReference);

            // Add message to active shops
            activeShops.Add(userMessage.Id, message.Author.Id);

            await userMessage.AddReactionsAsync(shopItems.Select(x => x.ReactionEmote).ToArray());

            Program.DiscordClient.ReactionAdded += OnReactionAdded;

            // Stop shop after delay
            _ = Task.Run(async() => await StopShopListener(userMessage));

            return(Task.CompletedTask);
        }
Exemplo n.º 11
0
        private async void UpdateOrAddRoleMessage()
        {
            if (RoleManager.roleChannel == null)
            {
                return;
            }
            if (games.Count == 0)
            {
                return;
            }

            ISocketMessageChannel chan  = RoleManager.roleChannel as ISocketMessageChannel;
            EmbedBuilder          embed = new EmbedBuilder();

            embed.WithTitle("Game Roles");

            string        roles_txt = "";
            List <IEmote> emotes    = new List <IEmote>();

            for (int i = 0; i < games.Count && i < GlobalUtils.menu_emoji.Count <string>(); i++)
            {
                Emoji emoji = new Emoji(GlobalUtils.menu_emoji[i]);
                emotes.Add(emoji);
                roles_txt += $"{GlobalUtils.menu_emoji[i]} {games[i].game}\n";
            }

            embed.WithDescription(roles_txt);
            embed.WithColor(GlobalUtils.color);

            if (roleMessageId == 0)
            {
                RestUserMessage msg = await chan.SendMessageAsync("", false, embed.Build());

                roleMessageId = msg.Id;
                await msg.AddReactionsAsync(emotes.ToArray());
            }
            else
            {
                if (!(await chan.GetMessageAsync(roleMessageId) is RestUserMessage msg))
                {
                    RestUserMessage msg2 = await chan.SendMessageAsync("", false, embed.Build());

                    roleMessageId = msg2.Id;
                    await msg2.AddReactionsAsync(emotes.ToArray());
                }
Exemplo n.º 12
0
        public async Task GetMarketBoardItem(CommandMessage message, ulong itemId)
        {
            Embed embed = await this.GetMarketBoardEmbed(itemId);

            RestUserMessage mbEmbedMessage = await message.Channel.SendMessageAsync(embed : embed);

            await mbEmbedMessage.AddReactionsAsync(MBEmotes.ToArray());

            // Add to window list
            activeMBEmbeds.Add(mbEmbedMessage.Id, new ActiveMBWindow(message.Author.Id, itemId, null, false));

            // Begin the clean up task if it's not already running
            if (activeMBWindowTask == null || !activeMBWindowTask.Status.Equals(TaskStatus.Running))
            {
                Program.DiscordClient.ReactionAdded += this.OnReactionAdded;
                activeMBWindowTask = Task.Run(async() => await this.ClearReactionsAfterDelay(message.Channel));
            }
        }
Exemplo n.º 13
0
        public async Task SendRoleMessage()
        {
            EmbedBuilder builder = new EmbedBuilder();

            builder.WithColor(0, 255, 255);
            builder.WithTitle("Get your roles here:");
            builder.WithDescription("You can assign yourself roles to get be able to have more permissions, turn off and on notification and view more channels.\n" +
                                    "You can do this by simply reacting to this message with the appropriate emote.");
            builder.AddField("Stream Notifications", new Emoji("\U0001F514"), true);
            builder.AddField("Cyber Security", new Emoji("\U0001F575"), true);
            builder.AddField("Programming", new Emoji("\U0001F4BB"), true);

            RestUserMessage message = await DiscordBot.client.GetGuild(Context.Guild.Id).GetTextChannel(DiscordBot.roleChannelID).SendMessageAsync(null, false, builder.Build());

            await message.AddReactionsAsync(new Emoji[] { new Emoji("\U0001F514"), new Emoji("\U0001F575"), new Emoji("\U0001F4BB") });

            await ReplyAsync("The message has been send.");
        }
Exemplo n.º 14
0
        public ReactionDialog(RestUserMessage message, SocketCommandContext context, Action onConfirm, Action onCancel,
                              bool senderOnly, bool shouldDeleteAfter, ulong botId)
        {
            _message = message;
            _event   = new ReactionEvent {
                Message = message.Id, Event = OnReactionClicked
            };
            _context      = context;
            _senderOnly   = senderOnly;
            _shouldDelete = shouldDeleteAfter;
            _onConfirm    = onConfirm;
            _onCancel     = onCancel;
            _botID        = botId;

            //Setup emojis
            message.AddReactionsAsync(new IEmote[]
            {
                new Emoji("✅"),
                new Emoji("❌")
            }).ContinueWith(e => { ReactionService.Instance.AddReactionEvent(_event); });
        }
Exemplo n.º 15
0
        protected async Task <bool> MoveMessageAsync(IMessageChannel oldChannel, ulong msgId, IMessageChannel newChannel, string footer, bool delOld = true)
        {
            if (!(await InitMessage(oldChannel, msgId, new string[] { footer, "React-for-Role" }, false)))
            {
                return(false);                                                                                            //finds and sets _msg and _oldEmbed
            }
            if (_oldEmbed.Footer != null)
            {
                if (_oldEmbed.Footer.Value.Text != "React-for-Role Embed")
                {
                    EmbedBuilder builder = _oldEmbed.ToEmbedBuilder();
                    builder.Footer.Text = "React-for-Role Embed";
                    _newEmbed           = builder.Build();
                }
                else
                {
                    _newEmbed = _oldEmbed;
                }
            }
            RestUserMessage newMsg = await newChannel.SendMessageAsync("", false, _newEmbed) as RestUserMessage;

            try
            {
                IEmote[] emotes = _msg.Reactions.Keys.ToArray();
                await newMsg.AddReactionsAsync(emotes);

                if (delOld)
                {
                    await _msg.DeleteAsync();
                }
                _msg = newMsg;
            }
            catch (Exception e)
            {
                await ReplyAsync(e.Message);

                return(false);
            }
            return(true);
        }
Exemplo n.º 16
0
        public async Task POI([Summary("Get information for this Point of Interest.")][Remainder] string poi)
        {
            ulong guild   = Context.Guild.Id;
            POI   pkmnPOI = Connections.Instance().GetPOI(guild, poi);

            if (pkmnPOI == null)
            {
                pkmnPOI = Connections.Instance().GetPOI(guild, Connections.Instance().GetPOIWithNickname(guild, poi));

                if (pkmnPOI == null)
                {
                    List <string> gymNames = Connections.Instance().SearchPOI(guild, poi);
                    Connections.CopyFile(UNKNOWN_POI_IMAGE);
                    RestUserMessage poiMessage = await Context.Channel.SendFileAsync(UNKNOWN_POI_IMAGE, embed : BuildSelectEmbed(gymNames, UNKNOWN_POI_IMAGE));

                    Connections.DeleteFile(UNKNOWN_POI_IMAGE);
                    poiMessages.Add(poiMessage.Id, gymNames);
                    poiMessage.AddReactionsAsync(Global.SELECTION_EMOJIS.Take(gymNames.Count).ToArray());
                }
                else
                {
                    string fileName = pkmnPOI.IsGym ? GYM_IMAGE : STOP_IMAGE;
                    pkmnPOI.Nicknames = Connections.Instance().GetPOINicknames(guild, pkmnPOI.Name);
                    Connections.CopyFile(fileName);
                    await Context.Channel.SendFileAsync(fileName, embed : BuildPOIEmbed(pkmnPOI, fileName));

                    Connections.CopyFile(fileName);
                }
            }
            else
            {
                string fileName = pkmnPOI.IsGym ? GYM_IMAGE : STOP_IMAGE;
                pkmnPOI.Nicknames = Connections.Instance().GetPOINicknames(guild, pkmnPOI.Name);
                Connections.CopyFile(fileName);
                await Context.Channel.SendFileAsync(fileName, embed : BuildPOIEmbed(pkmnPOI, fileName));

                Connections.CopyFile(fileName);
            }
        }
Exemplo n.º 17
0
        private async Task MessageReceivedAsync(SocketMessage message)
        {
            if (message.Author.Id != 142722503159185408)
            {
                return;
            }
            string command = "tsns.sendroleselect";
            string content = message.Content;

            if (content.ToLower().StartsWith(command))
            {
                await message.DeleteAsync();

                using (var db = new DbEntities()) {
                    SocketGuild       guild = ((SocketGuildChannel)message.Channel).Guild;
                    RoleSelectMessage lastRoleSelectMessageDb = db.RoleSelectMessages.FirstOrDefault(x => x.GuildId == guild.Id);
                    if (lastRoleSelectMessageDb != null)
                    {
                        if (guild.GetTextChannel(lastRoleSelectMessageDb.ChannelId) != null)
                        {
                            IMessage lastRoleSelectMessage = await guild.GetTextChannel(lastRoleSelectMessageDb.ChannelId).GetMessageAsync(lastRoleSelectMessageDb.MessageId);

                            if (lastRoleSelectMessage != null)
                            {
                                await lastRoleSelectMessage.DeleteAsync();
                            }
                        }

                        db.RoleSelectMessages.Remove(lastRoleSelectMessageDb);
                    }
                    RestUserMessage roleSelectMessage = await message.Channel.SendMessageAsync(content.Substring(command.Length + 1, content.Length - (command.Length + 1)));

                    db.RoleSelectMessages.Add(new RoleSelectMessage(guild.Id, roleSelectMessage.Channel.Id, roleSelectMessage.Id));
                    _ = roleSelectMessage.AddReactionsAsync(_emojiMap.Keys.ToArray());
                    await db.SaveChangesAsync();
                }
            }
        }
Exemplo n.º 18
0
        public async Task NewVote([Remainder] string selection = "")
        {
            try {
                //Create instance of servers and votes if it does not already exist.
                if (ServersAndVotes == null)
                {
                    ServersAndVotes = new Dictionary <ulong, RankedServerVote>();
                }

                //Vote has already started, do not continue
                if (ServersAndVotes.ContainsKey(Context.Guild.Id))
                {
                    await Context.Channel.SendMessageAsync("A vote is already running, please end the current one before starting a new one!");

                    return;
                }
                ServerData sd   = ServerData.Get(Context.Guild);
                Movie[]    movs = null;
                if (selection == "")
                {
                    //Get the movies to vote on
                    movs = sd.GetMovieSelection(sd.MovieVoteOptionCount);
                }
                else
                {
                    string[] titles = selection.Split(";");
                    movs = new Movie[titles.Length];
                    for (int i = 0; i < movs.Length; i++)
                    {
                        movs[i]       = new Movie();
                        movs[i].Title = titles[i];
                    }
                }
                //Generate the ranked vote object
                RankedServerVote serverVote = new RankedServerVote(Context.Guild, movs, Context.Channel);

                //build and send out the voting embed
                Embed embed = serverVote.MakeVoteEmbed();
                //Send the message out
                RestUserMessage mess = await Context.Channel.SendMessageAsync("Movie Vote!!!", embed : embed).ConfigureAwait(false);

                Emoji[] votes = new Emoji[movs.Length + 1];
                //React with the voting reactions
                for (int i = 0; i < movs.Length; i++)
                {
                    votes[i] = MojiCommand.VoteMoji[i];
                }
                votes[votes.Length - 1] = MojiCommand.CommandMoji[1];
                await mess.AddReactionsAsync(votes);

                //Finally add this vote object to the dictionary for later reference
                serverVote.voteMessage = mess;
                ServersAndVotes.Add(Context.Guild.Id, serverVote);
            } catch (DataException ex) {
                await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A data related exception was raised.", ex));

                await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:");
            } catch (Exception ex) {
                await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A general exception was raised.", ex));

                await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:");
            }
        }
Exemplo n.º 19
0
        public async Task Raid([Summary("Tier of the raid.")] string tier,
                               [Summary("Time the raid will start.")] string time,
                               [Summary("Where the raid will be.")][Remainder] string location)
        {
            short calcTier = Global.RAID_TIER_STRING.ContainsKey(tier) ? Global.RAID_TIER_STRING[tier] : Global.INVALID_RAID_TIER;
            Dictionary <int, List <string> > allBosses = Connections.Instance().GetFullBossList();
            List <string> potentials = calcTier == Global.INVALID_RAID_TIER || !allBosses.ContainsKey(calcTier) ? new List <string>() : allBosses[calcTier];
            Raid          raid;
            string        fileName;

            if (potentials.Count > 1)
            {
                fileName = $"Egg{calcTier}.png";
                raid     = new Raid(calcTier, time, location)
                {
                    AllBosses = allBosses
                };

                Connections.CopyFile(fileName);
                RestUserMessage selectMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildBossSelectEmbed(potentials, fileName));

                raidMessages.Add(selectMsg.Id, raid);
                Connections.DeleteFile(fileName);
                selectMsg.AddReactionsAsync(Global.SELECTION_EMOJIS.Take(potentials.Count).ToArray());
            }
            else if (potentials.Count == 1)
            {
                string boss = potentials.First();
                raid = new Raid(calcTier, time, location, boss)
                {
                    AllBosses = allBosses
                };
                fileName = Connections.GetPokemonPicture(raid.GetCurrentBoss());

                Connections.CopyFile(fileName);
                RestUserMessage raidMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildRaidEmbed(raid, fileName));

                raidMessages.Add(raidMsg.Id, raid);
                Connections.DeleteFile(fileName);
                SetEmojis(raidMsg, raidEmojis);
            }
            else if (Global.USE_EMPTY_RAID)
            {
                string boss = Global.DEFAULT_RAID_BOSS_NAME;
                raid = new Raid(calcTier, time, location, boss)
                {
                    AllBosses = allBosses
                };
                fileName = Connections.GetPokemonPicture(raid.GetCurrentBoss());

                Connections.CopyFile(fileName);
                RestUserMessage raidMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildRaidEmbed(raid, fileName));

                raidMessages.Add(raidMsg.Id, raid);
                Connections.DeleteFile(fileName);
                SetEmojis(raidMsg, raidEmojis);
            }
            else
            {
                await ResponseMessage.SendErrorMessage(Context.Channel, "raid", $"No raid bosses found for tier {tier}");
            }
            RemoveOldRaids();
        }
Exemplo n.º 20
0
        public async Task Catch([Summary("Simulate catching this Pokémon.")][Remainder] string pokemon)
        {
            bool isNumber = int.TryParse(pokemon, out int pokemonNum);

            if (isNumber)
            {
                List <string> pokemonWithNumber = Connections.Instance().GetPokemonByNumber(pokemonNum);

                if (pokemonWithNumber.Count == 0 || pokemonNum == 0)
                {
                    await ResponseMessage.SendErrorMessage(Context.Channel, "catch", $"Pokémon with number {pokemonNum} cannot be found.");
                }
                else if (pokemonWithNumber.Count > 1 && pokemonNum != Global.UNOWN_NUMBER && pokemonNum != Global.ARCEUS_NUMBER)
                {
                    string fileName = POKEDEX_SELECTION_IMAGE;
                    Connections.CopyFile(fileName);
                    RestUserMessage dexMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildDexSelectEmbed(pokemonWithNumber, fileName));

                    dexSelectMessages.Add(dexMessage.Id, new DexSelectionMessage((int)DEX_MESSAGE_TYPES.CATCH_MESSAGE, pokemonWithNumber));
                    Connections.DeleteFile(fileName);
                    dexMessage.AddReactionsAsync(Global.SELECTION_EMOJIS.Take(pokemonWithNumber.Count).ToArray());
                }
                else
                {
                    Pokemon         pkmn     = Connections.Instance().GetPokemon(pokemonWithNumber.First());
                    CatchSimulation catchSim = new CatchSimulation(pkmn);
                    string          fileName = Connections.GetPokemonPicture(pkmn.Name);
                    Connections.CopyFile(fileName);
                    RestUserMessage catchMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildCatchEmbed(catchSim, fileName));

                    catchMessages.Add(catchMessage.Id, catchSim);
                    Connections.DeleteFile(fileName);
                    catchMessage.AddReactionsAsync(catchEmojis);
                }
            }
            else
            {
                string  name = GetPokemonName(pokemon);
                Pokemon pkmn = Connections.Instance().GetPokemon(name);
                if (pkmn == null || pkmn.Name.Equals(Global.DUMMY_POKE_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    pkmn = Connections.Instance().GetPokemon(Connections.Instance().GetPokemonWithNickname(Context.Guild.Id, name));

                    if (pkmn == null || pkmn.Name.Equals(Global.DUMMY_POKE_NAME, StringComparison.OrdinalIgnoreCase))
                    {
                        List <string> pokemonNames = Connections.Instance().SearchPokemon(name);

                        string fileName = POKEDEX_SELECTION_IMAGE;
                        Connections.CopyFile(fileName);
                        RestUserMessage dexMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildDexSelectEmbed(pokemonNames, fileName));

                        dexSelectMessages.Add(dexMessage.Id, new DexSelectionMessage((int)DEX_MESSAGE_TYPES.CATCH_MESSAGE, pokemonNames));
                        Connections.DeleteFile(fileName);
                        dexMessage.AddReactionsAsync(Global.SELECTION_EMOJIS);
                    }
                    else
                    {
                        CatchSimulation catchSim = new CatchSimulation(pkmn);
                        string          fileName = Connections.GetPokemonPicture(pkmn.Name);
                        Connections.CopyFile(fileName);
                        RestUserMessage catchMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildCatchEmbed(catchSim, fileName));

                        catchMessages.Add(catchMessage.Id, catchSim);
                        Connections.DeleteFile(fileName);
                        catchMessage.AddReactionsAsync(catchEmojis);
                    }
                }
                else
                {
                    CatchSimulation catchSim = new CatchSimulation(pkmn);
                    string          fileName = Connections.GetPokemonPicture(pkmn.Name);
                    Connections.CopyFile(fileName);
                    RestUserMessage catchMessage = await Context.Channel.SendFileAsync(fileName, embed : BuildCatchEmbed(catchSim, fileName));

                    catchMessages.Add(catchMessage.Id, catchSim);
                    Connections.DeleteFile(fileName);
                    catchMessage.AddReactionsAsync(catchEmojis);
                }
            }
        }
Exemplo n.º 21
0
        public async Task ReactRolesInitializeAsync()
        {
            if (!(Program.Singleton.Client.GetChannel(621645734651101194) is SocketTextChannel channel))
            {
                return;
            }

            List <GuildEmote> arGenderGEmotes = ReactManager.Singleton.GuildEmotesGender;
            RestUserMessage   msgGender       = await channel.SendMessageAsync(
                "**Gender**\n" +
                $"{arGenderGEmotes[0].ToString()} Male\n" +
                $"{arGenderGEmotes[1].ToString()} Female\n" +
                $"{arGenderGEmotes[2].ToString()} Other");

            List <IEmote> arGenderEmotes = ReactManager.Singleton.EmotesGender;
            await msgGender.AddReactionsAsync(new IEmote[] { arGenderEmotes[0], arGenderEmotes[1], arGenderEmotes[2] });

            List <GuildEmote> arHomeGEmotes = ReactManager.Singleton.GuildEmotesHome;
            RestUserMessage   msgHome       = await channel.SendMessageAsync("\n" +
                                                                             "**Homeland**\n" +
                                                                             $"{arHomeGEmotes[0].ToString()} North America\n" +
                                                                             $"{arHomeGEmotes[1].ToString()} South America\n" +
                                                                             $"{arHomeGEmotes[2].ToString()} Oceania\n" +
                                                                             $"{arHomeGEmotes[3].ToString()} Europe\n" +
                                                                             $"{arHomeGEmotes[4].ToString()} Asia\n" +
                                                                             $"{arHomeGEmotes[5].ToString()} Africa");

            List <IEmote> arHomeEmotes = ReactManager.Singleton.EmotesHome;
            await msgHome.AddReactionsAsync(new IEmote[]
            {
                arHomeEmotes[0], arHomeEmotes[1], arHomeEmotes[2], arHomeEmotes[3], arHomeEmotes[4], arHomeEmotes[5]
            });

            RestUserMessage msgZodiac = await channel.SendMessageAsync("\n" +
                                                                       "**Zodiac Sign**\n" +
                                                                       "♒ Aquarius\n" +
                                                                       "♓ Pisces\n" +
                                                                       "♈ Aries\n" +
                                                                       "♉ Taurus\n" +
                                                                       "♊ Gemini\n" +
                                                                       "♋ Cancer\n" +
                                                                       "♌ Leo\n" +
                                                                       "♍ Virgo\n" +
                                                                       "♎ Libra\n" +
                                                                       "♏ Scorpio\n" +
                                                                       "♐ Sagittarius\n" +
                                                                       "♑ Capricorn");

            List <Emoji> arEmojiZodiac = ReactManager.Singleton.EmojiZodiac;
            await msgZodiac.AddReactionsAsync(new IEmote[]
            {
                arEmojiZodiac[0], arEmojiZodiac[1], arEmojiZodiac[2],
                arEmojiZodiac[3], arEmojiZodiac[4], arEmojiZodiac[5],
                arEmojiZodiac[6], arEmojiZodiac[7], arEmojiZodiac[8],
                arEmojiZodiac[9], arEmojiZodiac[10], arEmojiZodiac[11]
            });

            List <GuildEmote> arMBTIGEmotes = ReactManager.Singleton.GuildEmotesMBTI;
            RestUserMessage   msgMBTI       = await channel.SendMessageAsync("\n" +
                                                                             "**MBTI Personality type**\n" +
                                                                             $"{arMBTIGEmotes[0].ToString()} INTJ - Architect\n" +
                                                                             $"{arMBTIGEmotes[1].ToString()} INTP - Logician\n" +
                                                                             $"{arMBTIGEmotes[2].ToString()} ENTJ - Commander\n" +
                                                                             $"{arMBTIGEmotes[3].ToString()} ENTP - Debater\n" +
                                                                             $"{arMBTIGEmotes[4].ToString()} INFJ - Advocate\n" +
                                                                             $"{arMBTIGEmotes[5].ToString()} INFP - Mediator\n" +
                                                                             $"{arMBTIGEmotes[6].ToString()} ENFJ - Protagonist\n" +
                                                                             $"{arMBTIGEmotes[7].ToString()} ENFP - Campaigner\n" +
                                                                             $"{arMBTIGEmotes[8].ToString()} ISTJ - Logistician\n" +
                                                                             $"{arMBTIGEmotes[9].ToString()} ISFJ - Defender\n" +
                                                                             $"{arMBTIGEmotes[10].ToString()} ESTJ - Executive\n" +
                                                                             $"{arMBTIGEmotes[11].ToString()} ESFJ - Consul\n" +
                                                                             $"{arMBTIGEmotes[12].ToString()} ISTP - Virtuoso\n" +
                                                                             $"{arMBTIGEmotes[13].ToString()} ISFP - Adventurer\n" +
                                                                             $"{arMBTIGEmotes[14].ToString()} ESTP - Entrerpreneur\n" +
                                                                             $"{arMBTIGEmotes[15].ToString()} ESFP - Entertainer");

            List <IEmote> arMBTIEmotes = ReactManager.Singleton.EmotesMBTI;
            await msgMBTI.AddReactionsAsync(new IEmote[]
            {
                arMBTIEmotes[0], arMBTIEmotes[1], arMBTIEmotes[2], arMBTIEmotes[3],
                arMBTIEmotes[4], arMBTIEmotes[5], arMBTIEmotes[6], arMBTIEmotes[7],
                arMBTIEmotes[8], arMBTIEmotes[9], arMBTIEmotes[10], arMBTIEmotes[11],
                arMBTIEmotes[12], arMBTIEmotes[13], arMBTIEmotes[14], arMBTIEmotes[15]
            });
        }
Exemplo n.º 22
0
        public async Task Edit([Summary("Portion of the raid message to edit.")] string attribute,
                               [Summary("New value of the edited attribute.")][Remainder] string value)
        {
            ulong             raidMessageId = Context.Message.Reference.MessageId.Value;
            SocketUserMessage raidMessage   = (SocketUserMessage)await Context.Channel.GetMessageAsync(raidMessageId);

            RaidParent parent = raidMessages[raidMessageId];

            if (!parent.IsSingleStop() && !Context.Message.Author.Equals(parent.Conductor))
            {
                await ResponseMessage.SendErrorMessage(raidMessage.Channel, "edit", $"Command can only be run by the current conductor.");
            }
            else
            {
                ISocketMessageChannel channel = raidMessage.Channel;
                bool needsEdit = false;
                if (attribute.Equals("time", StringComparison.OrdinalIgnoreCase))
                {
                    parent.UpdateRaidInformation(value, null);
                    needsEdit = true;
                }
                else if (attribute.Equals("location", StringComparison.OrdinalIgnoreCase) || attribute.Equals("loc", StringComparison.OrdinalIgnoreCase))
                {
                    parent.UpdateRaidInformation(null, value);
                    needsEdit = true;
                }
                else if (attribute.Equals("tier", StringComparison.OrdinalIgnoreCase) || attribute.Equals("boss", StringComparison.OrdinalIgnoreCase))
                {
                    short calcTier = Global.RAID_TIER_STRING.ContainsKey(value) ? Global.RAID_TIER_STRING[value] : Global.INVALID_RAID_TIER;

                    if (calcTier == Global.INVALID_RAID_TIER)
                    {
                        await ResponseMessage.SendErrorMessage(channel, "edit", $"No raid bosses found for tier {value}.");
                    }
                    else
                    {
                        SocketGuildUser author = (SocketGuildUser)Context.Message.Author;
                        if (parent.IsSingleStop())
                        {
                            parent.BossEditingPlayer = author;
                        }
                        parent.SelectionTier = calcTier;
                        RestUserMessage bossMsg = await Context.Channel.SendMessageAsync(text : $"{author.Mention}",
                                                                                         embed : BuildBossSelectEmbed(parent.AllBosses[calcTier], null, true));

                        subMessages.Add(bossMsg.Id, new RaidSubMessage((int)SUB_MESSAGE_TYPES.EDIT_BOSS_SUB_MESSAGE, raidMessage.Id));
                        IEmote[] emotes = Global.SELECTION_EMOJIS.Take(parent.AllBosses[calcTier].Count).ToArray();
                        bossMsg.AddReactionsAsync(emotes.Append(extraEmojis[(int)EXTRA_EMOJI_INDEX.CHANGE_TIER]).Append(extraEmojis[(int)EXTRA_EMOJI_INDEX.CANCEL]).ToArray());
                    }
                }
                else
                {
                    await ResponseMessage.SendErrorMessage(channel, "edit", "Please enter a valid field to edit.");
                }

                if (needsEdit)
                {
                    await ModifyMessage(raidMessage, parent);

                    await Context.Channel.SendMessageAsync(BuildEditPingList(parent.GetAllUsers().ToImmutableList(), (SocketGuildUser)Context.Message.Author, attribute, value));
                }
            }
            await Context.Message.DeleteAsync();
        }