Ejemplo n.º 1
0
        public async Task AddReactionsAsync(IUserMessage message, IGuild guild)
        {
            var guildId = guild.Id.ToString();

            var dbGuild = await this.db.Guilds.FirstOrDefaultAsync(f => f.DiscordGuildId == guild.Id);

            if (dbGuild?.EmoteReactions == null || !dbGuild.EmoteReactions.Any())
            {
                return;
            }

            foreach (var emoteString in dbGuild.EmoteReactions)
            {
                if (emoteString.Length == 2)
                {
                    var emote = new Emoji(emoteString);
                    await message.AddReactionAsync(emote);
                }
                else
                {
                    var emote = Emote.Parse(emoteString);
                    await message.AddReactionAsync(emote);
                }
            }
        }
Ejemplo n.º 2
0
        private async Task BuildProgressTrackerPostAsync(ChallengeRank cr, string ThingToTrack, IUserMessage messageToEdit = null)
        {
            if (messageToEdit == null)
            {
                var tracker = new ProgressTrackerInfo(cr, ThingToTrack);
                messageToEdit = ReplyAsync(embed: tracker.BuildEmbed() as Embed).Result;
            }
            else
            {
                var tracker = new ProgressTrackerInfo().PopulateFromMessage(messageToEdit, cr);
                await messageToEdit.ModifyAsync(msg =>
                {
                    msg.Content = string.Empty;
                    msg.Embed   = tracker.BuildEmbed() as Embed;
                });
            }

            await messageToEdit.RemoveAllReactionsAsync();

            _ = Task.Run(async() =>
            {
                await messageToEdit.AddReactionAsync(DecreaseEmoji);
                await messageToEdit.AddReactionAsync(IncreaseEmoji);
                await messageToEdit.AddReactionAsync(FullEmoji);
                await messageToEdit.AddReactionAsync(RollEmoji);
                await messageToEdit.AddReactionAsync(new Emoji(GenericReactions.recreatePostEmoji));
            }).ConfigureAwait(false);

            return;
        }
Ejemplo n.º 3
0
        public async Task Poll(
            int time,
            [Summary("Title to display for the poll.")]
            params string[] titleStrings)
        {
            string title = string.Join(" ", titleStrings);

            IUserMessage message = await this.ReplyAsync($"Vote on {this.Context.User.Username}'s poll with reactions\n**{title}**\nYou have {time} seconds to vote.");

            await message.AddReactionAsync(new Emoji("👍"));

            await message.AddReactionAsync(new Emoji("👎"));

            await Task.Delay(new TimeSpan(0, 0, 0, time));

            EmbedBuilder resultsbuilder = new EmbedBuilder();

            IUserMessage updatedmessage = (IUserMessage)await this.Context.Channel.GetMessageAsync(message.Id);

            int upReactionCount = updatedmessage.Reactions.Values.Where(e => e.IsMe).ElementAt(0).ReactionCount - 1;

            int downReactionCount = updatedmessage.Reactions.Values.Where(e => e.IsMe).ElementAt(1).ReactionCount - 1;

            resultsbuilder.Description = $"👍 {upReactionCount}             👎 {downReactionCount}";

            await this.ReplyAsync($"Results of {this.Context.User.Mention}'s poll \"{title}\":", false, resultsbuilder.Build());

            foreach (KeyValuePair <IEmote, ReactionMetadata> updatedmessageReaction in updatedmessage.Reactions)
            {
                Console.Out.WriteLine($"Emote {updatedmessageReaction.Key.Name} with {updatedmessageReaction.Value.ReactionCount} reactions");
            }
        }
Ejemplo n.º 4
0
        private async Task HandleAddAsync(PlayerInfo player, ulong wid, IUserMessage message)
        {
            var card = player.Dbuser.GameDeck.Cards.FirstOrDefault(x => x.Id == wid);

            if (card == null)
            {
                await message.AddReactionAsync(ErrEmote);

                return;
            }

            if (card.InCage || !card.IsTradable || card.IsBroken())
            {
                await message.AddReactionAsync(ErrEmote);

                return;
            }

            if (player.Cards.Any(x => x.Id == card.Id))
            {
                return;
            }

            player.Cards.Add(card);
            player.Accepted     = false;
            player.CustomString = BuildProposition(player);

            await message.AddReactionAsync(InEmote);

            if (await Message.Channel.GetMessageAsync(Message.Id) is IUserMessage msg)
            {
                await msg.ModifyAsync(x => x.Embed = BuildEmbed());
            }
        }
Ejemplo n.º 5
0
        private async Task ReactWithSentiment([NotNull] IUserMessage message, SentimentResult?score = null)
        {
            var result = score ?? await _sentiment.Predict(message.Content);

            if (result.ClassificationScore < _config.CertaintyThreshold)
            {
                await message.AddReactionAsync(new Emoji(EmojiLookup.Confused));
            }

            switch (result.Classification)
            {
            case Moe.Services.Sentiment.Sentiment.Positive:
                await message.AddReactionAsync(new Emoji(EmojiLookup.ThumbsUp));

                break;

            case Moe.Services.Sentiment.Sentiment.Neutral:
                await message.AddReactionAsync(new Emoji(EmojiLookup.Expressionless));

                break;

            case Moe.Services.Sentiment.Sentiment.Negative:
                await message.AddReactionAsync(new Emoji(EmojiLookup.ThumbsDown));

                break;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles behaviour on reactions while in the startpage gamestate
        /// </summary>
        private async Task HandleStartPageInput(IUserMessage socketMsg, IReaction reaction)
        {
            var reactionName = reaction.Emote.Name;

            // If the player wants to change the category
            if (reactionName == _triviaGames.ReactOptions["1"].Name)
            {
                socketMsg.AddReactionAsync(_triviaGames.ReactOptions["left"]);
                socketMsg.AddReactionAsync(_triviaGames.ReactOptions["right"]);
                PrepareCategoryEmb();
                _gamestate = GameStates.ChangingCategory;
                return;
            }
            // If the player wants to change the questiontype
            if (reactionName == _triviaGames.ReactOptions["2"].Name)
            {
                // Take the current type and use set it to the next one
                var index = _triviaGames.QuestionTypes.ToList().FindIndex(q => QuestionType == q.Key);
                QuestionType = _triviaGames.QuestionTypes.ToList()[(index + 1) % _triviaGames.QuestionTypes.Count].Key;
                PrepareStartMenue(socketMsg);
            }
            // If the player wants to change the difficulty
            else if (reactionName == _triviaGames.ReactOptions["3"].Name)
            {
                // Take the current difficulty and use set it to the next one
                var index = _triviaGames.Difficulties.ToList().FindIndex(q => Difficulty == q.Key);
                Difficulty = _triviaGames.Difficulties.ToList()[(index + 1) % _triviaGames.Difficulties.Count].Key;
                PrepareStartMenue(socketMsg);
            }
            // If the player wants to start the game
            if (reactionName == _triviaGames.ReactOptions["ok"].Name)
            {
                await PreparePlayEmb(socketMsg, reaction);
            }
        }
Ejemplo n.º 7
0
        private async Task MakePlanetPost(SpaceRegion region, string PlanetName, IUserMessage message = null)
        {
            Planet planet = Planet.GeneratePlanet(PlanetName, region, Services);

            if (message != null)
            {
                await message.RemoveAllReactionsAsync();

                await message.ModifyAsync(msg => msg.Embed = planet.GetEmbedBuilder().Build());
            }
            else
            {
                message = await ReplyAsync(embed : planet.GetEmbedBuilder().Build());
            }

            _ = Task.Run(async() =>
            {
                await message.AddReactionAsync(new Emoji("🔍"));
                await message.AddReactionAsync(new Emoji("\U0001F996"));

                if (planet.NumberOfBiomes > 1)
                {
                    var biome = new Emoji("\uD83C\uDF0D");
                    await message.AddReactionAsync(biome);
                }
            }).ConfigureAwait(false);
        }
Ejemplo n.º 8
0
        private async Task HandleDeleteAsync(PlayerInfo player, ulong wid, IUserMessage message)
        {
            var card = player.Cards.FirstOrDefault(x => x.Id == wid);

            if (card == null)
            {
                await message.AddReactionAsync(ErrEmote);

                return;
            }

            if (!player.Cards.Any(x => x.Id == card.Id))
            {
                return;
            }

            player.Accepted = false;
            player.Cards.Remove(card);
            player.CustomString = BuildProposition(player);

            await message.AddReactionAsync(OutEmote);

            if (await Message.Channel.GetMessageAsync(Message.Id) is IUserMessage msg)
            {
                await msg.ModifyAsync(x => x.Embed = BuildEmbed());
            }
        }
        private async Task SettlementReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var settlementHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(SettlementResources.SettlementHelper) ?? false);

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

                string command  = settlementHelperEmbed.Fields.FirstOrDefault(fld => fld.Name == SettlementResources.SettlementName).Value ?? string.Empty;
                string location = ExtractAnySettlementLocation(ref command);

                var newSettlement = Settlement.GenerateSettlement(Services, region, channel.Id, command, location);
                Task.WaitAll(message.RemoveAllReactionsAsync());

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

                await Task.Run(async() =>
                {
                    await message.AddReactionAsync(projectEmoji);
                    await message.AddReactionAsync(contactEmoji);
                    await message.AddReactionAsync(troubleEmoji);
                }).ConfigureAwait(false);

                return;
            }
        }
Ejemplo n.º 10
0
        public static async Task TeamInviteEmojis(IUserMessage message)
        {
            //Check
            await message.AddReactionAsync(await GetEmoji(736480922152730665));

            //X
            await message.AddReactionAsync(await GetEmoji(736481999006466119));
        }
Ejemplo n.º 11
0
        private async Task ReactToAsync(IUserMessage response)
        {
            await response.AddReactionAsync(EmojiLibrary.DELETE);

            foreach (var zone in SecondaryTimezones)
            {
                await response.AddReactionAsync(zone.Value.Emoji);
            }
        }
Ejemplo n.º 12
0
        private async Task ReactToAsync(IUserMessage response)
        {
            await response.AddReactionAsync(EmojiLibrary.DELETE);

            foreach (var zone in SECONDARY_ZONES)
            {
                await response.AddReactionAsync(zone);
            }
        }
Ejemplo n.º 13
0
        public static async Task FightScreenEmojis(IUserMessage message)
        {
            await message.AddReactionAsync(new Emoji("⚔"));

            await message.AddReactionAsync(new Emoji("👜"));

            await message.AddReactionAsync(new Emoji("🔁"));

            await message.AddReactionAsync(new Emoji("🏃"));
        }
Ejemplo n.º 14
0
        private async Task AddPaginatorReactions(IUserMessage message)
        {
            await message.AddReactionAsync(new Emoji("⏮️"));

            await message.AddReactionAsync(new Emoji("◀️"));

            await message.AddReactionAsync(new Emoji("▶️"));

            await message.AddReactionAsync(new Emoji("⏭️"));
        }
Ejemplo n.º 15
0
        public async Task SendStartRecruit() {
            _ackUsers = new List<IUser>();
            _ackLame  = new List<IUser>();

            var channel = _discord.GetChannel(ulong.Parse(_config["sus_channel"])) as IMessageChannel;
            _lastNag = await channel.SendMessageAsync($"If you're available to play tonight, emote below.  If you would like to be included on all sus related messaging (like pings when we're gonna play), ask a queue captain to add you to the {SUSFAM_MENTION} role.");

            await _lastNag.AddReactionAsync(_ackYes);
            await _lastNag.AddReactionAsync(_ackNo);
        }
Ejemplo n.º 16
0
        private void SetupReactions()
        {
            if (embedPages.Count() == 1)
            {
                return;
            }

            myEmbedMessage.AddReactionAsync(backEmoji);
            myEmbedMessage.AddReactionAsync(forwardEmoji);
        }
        public async Task <bool> GetMovieRequestAsync()
        {
            await _lastCommandMessage?.AddReactionAsync(new Emoji("⬇"));

            await ReplyToUserAsync("If you want to request this movie please click on the ⬇ reaction.");

            var reaction = await WaitForReactionAsync(Context, _lastCommandMessage, new Emoji("⬇"));

            return(reaction != null);
        }
Ejemplo n.º 18
0
        public static async Task MoveScreenEmojis(IUserMessage message)
        {
            await message.AddReactionAsync(new Emoji("1\u20E3"));

            await message.AddReactionAsync(new Emoji("2\u20E3"));

            await message.AddReactionAsync(new Emoji("3\u20E3"));

            await message.AddReactionAsync(new Emoji("4\u20E3"));
        }
Ejemplo n.º 19
0
        public async Task AddQcmReactions(IUserMessage msg)
        {
            await msg.AddReactionAsync(new Emoji("🇦"));

            await msg.AddReactionAsync(new Emoji("🇧"));

            await msg.AddReactionAsync(new Emoji("🇨"));

            await msg.AddReactionAsync(new Emoji("🇩"));
        }
Ejemplo n.º 20
0
        public async Task RefreshNag() {
            await _lastNag.DeleteAsync();

            var channel = _discord.GetChannel(ulong.Parse(_config["sus_channel"])) as IMessageChannel;
            _lastNag = await channel.SendMessageAsync($"Refreshing...");

            await _lastNag.AddReactionAsync(_ackYes);
            await _lastNag.AddReactionAsync(_ackNo);

            await UpdateNag();
        }
Ejemplo n.º 21
0
        private async Task AddRuleboxReactions(Guild guild, IUserMessage rulebox)
        {
            var agreeEmote    = new Emoji(guild.Admin.Rulebox.AgreeEmote) as IEmote;
            var disagreeEmote = new Emoji(guild.Admin.Rulebox.DisagreeEmote) as IEmote;

            await rulebox.AddReactionAsync(agreeEmote);

            await rulebox.AddReactionAsync(disagreeEmote);

            await rulebox.PinAsync();
        }
Ejemplo n.º 22
0
        public override async Task Start(IUserMessage umsg, ICommandContext context)
        {
            StartingMessage         = umsg;
            _client.MessageDeleted += MessageDeletedEventHandler;

            var iemote = Emote.TryParse(_bc.CurrencySign, out var emote) ? emote : new Emoji(_bc.CurrencySign) as IEmote;

            try { await StartingMessage.AddReactionAsync(iemote).ConfigureAwait(false); }
            catch
            {
                try { await StartingMessage.AddReactionAsync(new Emoji("🌸")).ConfigureAwait(false); }
                catch
                {
                    try { await StartingMessage.DeleteAsync().ConfigureAwait(false); }
                    catch { return; }
                }
            }
            using (StartingMessage.OnReaction(_client, r =>
            {
                try
                {
                    if (r.UserId == _botUser.Id)
                    {
                        return;
                    }

                    if (string.Equals(r.Emote.Name, iemote.Name, StringComparison.Ordinal) && r.User.IsSpecified && (DateTime.UtcNow - r.User.Value.CreatedAt).TotalDays > 5 && _reactionAwardedUsers.Add(r.User.Value.Id))
                    {
                        _toGiveTo.Enqueue(r.UserId);
                    }
                }
                catch
                {
                    // ignored
                }
            }))
            {
                try
                {
                    await Task.Delay(TimeSpan.FromHours(24), CancelToken).ConfigureAwait(false);
                }
                catch (OperationCanceledException)
                {
                }
                if (CancelToken.IsCancellationRequested)
                {
                    return;
                }

                _log.Warn("Stopping reaction event because it expired.");
                await End();
            }
        }
Ejemplo n.º 23
0
        public async Task TrashPoll([Remainder] string input)
        {
            IGuildUser user = Context.User as IGuildUser;

            List <EmoteOrEmoji> items = Context.Message.Content.ParseDiscordMessageEmotes();
            string content            = Context.Message.Content;

            content = content.Remove(0, "!trashpoll".Length);

            foreach (EmoteOrEmoji item in items)
            {
                content = content.Replace(item.ToString(), "");
            }

            EmbedBuilder builder = new EmbedBuilder()
            {
                Color       = new Color(Constants.GeneralColor.R, Constants.GeneralColor.G, Constants.GeneralColor.B),
                Description = content
            };

            builder.Author = new EmbedAuthorBuilder()
            {
                IconUrl = user.GetAvatarUrl(),
                Name    = $"{(!string.IsNullOrWhiteSpace(user.Nickname) ? user.Nickname : user.Username)} asks"
            };

            builder.Footer = new EmbedFooterBuilder()
            {
                Text = "Answer using the reactions below"
            };

            await Context.Message.DeleteAsync();

            IUserMessage message = await BetterReplyAsync(builder.Build(), parameters : input);

            // Might throw if the bot does not have access to the emote
            foreach (EmoteOrEmoji item in items)
            {
                try {
                    if (item.IsEmoji)
                    {
                        await message.AddReactionAsync(new Emoji(item.ToString()));
                    }
                    else
                    {
                        if (Emote.TryParse(item.ToString(), out Emote emote))
                        {
                            await message.AddReactionAsync(emote);
                        }
                    }
                } catch { }
            }
        }
Ejemplo n.º 24
0
        private static async Task AddPaginationReactionsAsync(IUserMessage message, PaginatedMessage paginatedMsg)
        {
            await message.AddReactionAsync(new Emoji("◀")); // :arrow_backward:

            await message.AddReactionAsync(new Emoji("❌")); // :x:

            foreach (PaginatedMessageReaction customReaction in paginatedMsg.Reactions)
            {
                await message.AddReactionAsync(customReaction.Emote);
            }

            await message.AddReactionAsync(new Emoji("▶")); // :arrow_forward:
        }
Ejemplo n.º 25
0
        public static async Task PartyMenuEmojis(IUserMessage message, UserAccount user)
        {
            //Back Arrow
            await message.AddReactionAsync(await GetEmoji(735583967046271016));

            //Numbers
            for (int i = 1; i <= user.Char.Party.Count; i++)
            {
                await message.AddReactionAsync(new Emoji($"{i}\u20E3"));
            }
            //Swap
            await message.AddReactionAsync(await MessageHandler.GetEmoji(736070692373659730));
        }
        /// <summary>
        /// Adds a new TriviaGame to the active Trivia Games
        /// </summary>
        internal async Task NewTrivia(IUserMessage msg, IUser user)
        {
            _activeTriviaGames.Add(new TriviaGame(msg.Id, user.Id, this));
            await msg.AddReactionAsync(ReactOptions["1"]);

            await msg.AddReactionAsync(ReactOptions["2"]);

            await msg.AddReactionAsync(ReactOptions["3"]);

            await msg.AddReactionAsync(ReactOptions["4"]);

            await msg.AddReactionAsync(ReactOptions["ok"]);
        }
Ejemplo n.º 27
0
        public override async Task Start(IUserMessage umsg, ICommandContext context)
        {
            StartingMessage         = umsg;
            _client.MessageDeleted += MessageDeletedEventHandler;

            try { await StartingMessage.AddReactionAsync(new Emoji("🌸")).ConfigureAwait(false); }
            catch
            {
                try { await StartingMessage.AddReactionAsync(new Emoji("🌸")).ConfigureAwait(false); }
                catch
                {
                    try { await StartingMessage.DeleteAsync().ConfigureAwait(false); }
                    catch { return; }
                }
            }
            using (StartingMessage.OnReaction(_client, (r) =>
            {
                try
                {
                    if (r.UserId == _botUser.Id)
                    {
                        return;
                    }

                    if (r.Emote.Name == "🌸" && r.User.IsSpecified && ((DateTime.UtcNow - r.User.Value.CreatedAt).TotalDays > 5) && _flowerReactionAwardedUsers.Add(r.User.Value.Id))
                    {
                        _toGiveTo.Enqueue(r.UserId);
                    }
                }
                catch
                {
                    // ignored
                }
            }))
            {
                try
                {
                    await Task.Delay(TimeSpan.FromHours(24), CancelToken).ConfigureAwait(false);
                }
                catch (OperationCanceledException)
                {
                }
                if (CancelToken.IsCancellationRequested)
                {
                    return;
                }

                _log.Warn("Stopping flower reaction event because it expired.");
                await End();
            }
        }
Ejemplo n.º 28
0
        public async Task Announce()
        {
            ConfigFile.Announcement ann = Config.Announcement;

            EmbedBuilder embed = new EmbedBuilder();

            embed.WithTitle(ann.title);
            embed.WithDescription(ann.desc);
            foreach (ConfigFile.Announcement.Field field in ann.fields)
            {
                embed.AddField(field.title, field.content);
            }
            embed.WithFooter("Please leave any feedback about this update in #feedback.");
            embed.WithColor(114, 137, 218);

            IUserMessage testmsg = await ReplyAsync("", false, embed.Build());

            IUserMessage confirmationmessage = await ReplyAsync($"Please type `confirm` within 2 minutes to send this message to <#{Data.GetChnlId("announcements")}>.");

            SocketMessage reply = await NextMessageAsync(true, true, TimeSpan.FromSeconds(120));

            if (reply == null)
            {
                await testmsg.DeleteAsync();

                await confirmationmessage.AddReactionAsync(new Emoji("❌"));

                return;
            }
            else
            {
                switch (reply.Content)
                {
                case "confirm":
                    await testmsg.DeleteAsync();

                    SocketTextChannel AnnouncementChannel = Constants.IGuilds.Jordan(Context).Channels.FirstOrDefault(x => x.Id == Data.GetChnlId("announcements")) as SocketTextChannel;
                    await AnnouncementChannel.SendMessageAsync("@everyone", false, embed.Build());

                    //await AnnouncementChannel.SendMessageAsync("", false, embed.Build());
                    break;

                default:
                    await testmsg.DeleteAsync();

                    await confirmationmessage.AddReactionAsync(new Emoji("❌"));

                    return;
                }
            }
        }
Ejemplo n.º 29
0
        public async Task AddReactions()
        {
            try
            {
                await message.AddReactionAsync(new Emoji("⏮"));

                await message.AddReactionAsync(new Emoji("⏪"));

                await message.AddReactionAsync(new Emoji("⏩"));

                await message.AddReactionAsync(new Emoji("⏭"));
            }
            catch (Exception) { }
        }
Ejemplo n.º 30
0
        public static async Task PvPLobbyEmojis(IUserMessage message, UserAccount user)
        {
            //Back
            await message.AddReactionAsync(await GetEmoji(735583967046271016));

            //Ready Up
            await message.AddReactionAsync(await GetEmoji(736480922152730665));

            //Lobby Leaders Only
            if (user.HasLobby())
            {
                if (user.CombatLobby.IsLeader(user))
                {
                    //Invite Player
                    await message.AddReactionAsync(await GetEmoji(736476027886501888));

                    //Kick
                    await message.AddReactionAsync(await GetEmoji(736476054427795509));

                    //Lvl
                    await message.AddReactionAsync(await GetEmoji(827689938999836703));

                    //Bag
                    await message.AddReactionAsync(await GetEmoji(732676561341251644));

                    //Mon
                    await message.AddReactionAsync(await GetEmoji(827690265673203772));
                }
            }

            //Exit
            await message.AddReactionAsync(await GetEmoji(736485364700545075));
        }