コード例 #1
0
ファイル: Program.cs プロジェクト: Soverclysm/Exurb1aBot
        private async Task ReactionAdded(Cacheable <IUserMessage, ulong> ch, ISocketMessageChannel chanel, SocketReaction reaction)
        {
            IUserMessage msg = await ch.GetOrDownloadAsync();

            if ((/*msg.Id == SearchModule._tracked?.Id || */ AdminModule._trackedList?.Id == msg.Id) &&
                reaction.UserId != _client.CurrentUser.Id)
            {
                if (reaction.Emote.Name == "➡")
                {
                    /* if(msg.Id == SearchModule._tracked?.Id)
                     *   SearchModule.ChangeFrame(true);*/
                    //else
                    await AdminModule.ChangeIndex((ISocketMessageChannel)msg.Channel, true);
                }
                if (reaction.Emote.Name == "⬅")
                {
                    /* if (msg.Id == SearchModule._tracked?.Id)
                     *   SearchModule.ChangeFrame(false);
                     * else*/
                    await AdminModule.ChangeIndex((ISocketMessageChannel)msg.Channel, false);
                }
            }
            if (reaction.Emote.Name == "💬" && !msg.Author.IsBot)
            {
                try {
                    await QuoteModule.BotAddQuote(_services.GetService <IQouteRepository>(), chanel, msg.Content, msg.Id, reaction.User.GetValueOrDefault(null) as IGuildUser
                                                  , msg.Author as IGuildUser, msg.Timestamp.DateTime);
                }
                catch (Exception e) {
                    if (e.GetType().Equals(typeof(QuotingYourselfException)))
                    {
                        await msg.Channel.SendMessageAsync("A bit narcissistic to quote yourself, no?");
                    }
                }
            }
        }