Esempio n. 1
0
        public async Task SendRandomUserInternal(CommandContext Context, decimal Amount, UserStatus MinimumStatus = UserStatus.Offline)
        {
            await Context.TriggerTypingAsync();

            await LogHandlerService.LogUserActionAsync(Context, $"Invoked sending {Amount} to a random user with minimum status {MinimumStatus.ToString()}.");

            var Members     = DiscordHelpers.GetHumansInContextGuild(Context, true, MinimumStatus);
            int randomIndex = Program.RandomManager.GetRandomInteger(0, Members.Count() - 1);

            var Member = Members.ElementAt(randomIndex);

            if (Member.Value != null)
            {
                await SendDallarToUserInternal(Context, Amount.ToString(), Member.Value, true);
            }
            else
            {   // failed to get random member?
                await LogHandlerService.LogUserActionAsync(Context, $"Failed to get a random user from the guild.");

                await Context.RespondAsync($"{Context.User.Mention}: DallarBot has failed to get a random user from the guild. Please contact an Administrator.");

                _ = Context.Message.DeleteAsync();
            }
        }