コード例 #1
0
        public async Task Reddit(string subreddit, int amountOfRequests)
        {
            var guild = ((SocketGuildChannel)Context.Channel).Guild;

            //If the amount of requests is more than one ensure that it doesn't exceed the configured max requests.
            if (amountOfRequests > 1)
            {
                var maxBulkSetting = await _guildSettingsFactory.GetGuildSettingByKey <int>(guild.Id, DefaultSettingKeys.Bulk);

                var max = maxBulkSetting > 0 ? maxBulkSetting : 20;

                if (amountOfRequests > max)
                {
                    await ReplyAsync($"You can't place more than {max} requests at once.");

                    return;
                }
            }

            await Context.Channel.TriggerTypingAsync();

            await _queueFactory.AddToQueue(guild.Id, subreddit, Domain.Models.PostType.Image, ((SocketGuildChannel)Context.Channel).Id, amountOfRequests);
        }