public async Task GiveKarma(CommandContext context, [Description("The discord user you'd like to give karma.")] DiscordUser member)
        {
            if (member.Equals(context.Member))
            {
                await context.RespondAsync($"{context.Member.Mention}, you can't give yourself Karma. That would be cheating. You have to earn it from others.");

                return;
            }

            await context.Message.DeleteAsync();

            using IBotAccessProvider provider = this.providerBuilder.Build();

            ulong karmaToAdd = 0;

            for (int i = 0; i < 180; i++)
            {
                karmaToAdd += (ulong)this._rng.Next(1, 4);
            }

            provider.AddKarma(member.Id, context.Guild.Id, karmaToAdd);
            DiscordEmbed response = new DiscordEmbedBuilder()
                                    .WithDescription($"{member.Mention}, you have been bestowed {karmaToAdd} karma.");
            await context.RespondAsync(embed : response);
        }
Пример #2
0
        /// <summary>
        /// Checks if a message is a direct or indirect reply to the current user.
        /// An indirect reply is a message that is a reply of a reply [of a reply [...]] to a message by the current user.
        /// </summary>
        /// <param name="currentUser">User to check for</param>
        /// <param name="message">Root message</param>
        /// <returns>True if the message is a direct or indirect reply</returns>
        public static bool IsDeepReply(DiscordUser currentUser, DiscordMessage message)
        {
            for (var currentMessage = message; currentMessage != null; currentMessage = currentMessage.Reference?.Message)
            {
                // If we sent the message, then this is a loop
                if (currentUser.Equals(currentMessage.Author))
                {
                    return(true);
                }
            }

            // If we get to the end without a match, then this is not a loop
            return(false);
        }