Esempio n. 1
0
        public async Task Roll(params string[] s)
        {
            AnimaCharacter character = CharacterRepository.FindCurrentByMention <AnimaCharacter>(Context.Message.Author.Mention);

            if (character == null)
            {
                await Context.Channel.SendMessageAsync("Error 404: Character not found or not loaded!");

                return;
            }

            string statBonusStr = s.FirstOrDefault(x => x.StartsWith("+") || x.StartsWith("-"));
            int    bonus        = Convert.ToInt32(statBonusStr);
            string stat         = string.Join(" ", s).ToLower();

            if (!string.IsNullOrWhiteSpace(statBonusStr))
            {
                stat = stat.Replace($" {statBonusStr}", "");
            }

            if (stat == null || stat == string.Empty)
            {
                await Context.Message.DeleteAsync();

                await Context.Channel.SendMessageAsync(character.KeywordsHelp());
            }
            else
            {
                await Context.Message.DeleteAsync();

                await Context.Channel.SendMessageAsync(string.Format("{0} {1}",
                                                                     Context.User.Mention,
                                                                     character.Roll(stat, bonus)));
            }
        }
Esempio n. 2
0
        private async Task ReactionAddedOrRemoved(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.User.Value.IsBot)
            {
                return;
            }

            if (ReactionMessages.Contains(cache.Id))
            {
                AnimaCharacter character = CharacterRepository.FindCurrentByMention <AnimaCharacter>(reaction.User.Value.Mention);
                if (character == null)
                {
                    await channel.SendMessageAsync("Error 404: Character not found or not loaded!");

                    return;
                }

                await channel.SendMessageAsync(string.Format("{0} {1}",
                                                             reaction.User.Value.Mention,
                                                             character.Roll(EmotesAction[reaction.Emote].ToLower(), 0)));
            }
            if (HelpMessages.ContainsKey(cache.Id))
            {
                if (reaction.Emote.Name == "\U000025c0")//Previous page
                {
                    var msg = await cache.GetOrDownloadAsync();

                    await msg.ModifyAsync(x => {
                        x.Content = "";
                        x.Embed   = HelpMessages[cache.Id].GetPreviousPage().Build();
                    });
                }
                else if (reaction.Emote.Name == "\U000025b6")//Next page
                {
                    var msg = await cache.GetOrDownloadAsync();

                    await msg.ModifyAsync(x =>
                    {
                        x.Content = "";
                        x.Embed   = HelpMessages[cache.Id].GetNextPage().Build();
                    });
                }
            }
        }