Beispiel #1
0
        /// <summary>
        /// Logs a reaction in the database.
        /// </summary>
        /// <param name="channel">The channel that the emoji was used in.</param>
        /// <param name="message">The message associated with the emoji.</param>
        /// <param name="reaction">The emoji that was used.</param>
        /// <param name="emote">The emote that was used, if any.</param>
        /// <returns>
        /// A <see cref="Task"/> that will complete when the operation completes.
        /// </returns>
        private async Task LogReactionAsync(ITextChannel channel, IUserMessage message, ISocketReaction reaction, IEmoteEntity emote)
        {
            using (var transaction = await _emojiRepository.BeginMaintainTransactionAsync())
            {
                await _emojiRepository.CreateAsync(new EmojiCreationData()
                {
                    GuildId    = channel.GuildId,
                    ChannelId  = channel.Id,
                    MessageId  = message.Id,
                    UserId     = reaction.UserId,
                    EmojiId    = emote?.Id,
                    EmojiName  = reaction.Emote.Name,
                    IsAnimated = emote?.Animated ?? false,
                    UsageType  = EmojiUsageType.Reaction,
                });

                transaction.Commit();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Unlogs an emoji from the database.
 /// </summary>
 /// <param name="channel">The channel that the emoji was used in.</param>
 /// <param name="message">The message associated with the emoji.</param>
 /// <param name="reaction">The emoji that was used.</param>
 /// <param name="emote">The emote that was used, if any.</param>
 /// <returns>
 /// A <see cref="Task"/> that will complete when the operation completes.
 /// </returns>
 private async Task UnlogReactionAsync(ITextChannel channel, IUserMessage message, ISocketReaction reaction, IEmoteEntity emote)
 {
     using (var transaction = await _emojiRepository.BeginMaintainTransactionAsync())
     {
         await _emojiRepository.DeleteAsync(new EmojiSearchCriteria()
         {
             GuildId   = channel.GuildId,
             ChannelId = channel.Id,
             MessageId = message.Id,
             UserId    = reaction.UserId,
             EmojiId   = emote?.Id,
             EmojiName = emote is null
                 ? reaction.Emote.Name
                 : null,
             UsageType = EmojiUsageType.Reaction,
         });