Exemple #1
0
        private async Task PublishInSpecificGuildAsync(IReadOnlyCollection <SocketGuild> mutualGuilds, string content, ConfessionType type)
        {
            var guilds     = ConfessionModule.ToGuildArray(mutualGuilds);
            var guildIndex = await this.AttemptToGetSpecificGuildAsync(guilds);

            if (ConfessionModule.WithinArrayBounds(guilds, guildIndex))
            {
                await this.ConfessToGuildAsync(content, type, guilds[guildIndex]);

                await this.ReplyAsync(confessionbot_strings.ConfessionBotConfessionSent);
            }
            else
            {
                await this.ReplyAsync(confessionbot_strings.ConfessionBotConfessionFailed);
            }
        }
Exemple #2
0
        private async Task <int> AttemptToGetSpecificGuildAsync(SocketGuild[] guilds)
        {
            for (byte attempts = 0; attempts < 5; attempts++)
            {
                await this.SendServerListAsync(guilds);

                var choice = await this.GetChoiceFromUserAsync();

                if (ConfessionModule.WithinArrayBounds(guilds, choice))
                {
                    return(choice);
                }

                await this.ReplyAsync(confessionbot_strings.ConfessionBotInvalidResponse);
            }

            return(-1);
        }