Esempio n. 1
0
        private async Task PublishInAllMutualGuildsAsync(IReadOnlyCollection <SocketGuild> mutualGuilds, string content, ConfessionType type)
        {
            var embed = ConfessionModule.CreateConfessionEmbed(content, type);

            foreach (SocketGuild guild in mutualGuilds)
            {
                await this.ConfessToGuildAsync(embed, guild, type);
            }

            await this.ReplyAsync(confessionbot_strings.ConfessionBotConfessionSent);
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        private async Task ConfessToGuildAsync(Embed embed, SocketGuild guild, ConfessionType type)
        {
            var storage          = this.GetServerStorage(guild.Id);
            var publishChannelId = storage.GetNamedID(type.PublishChannelName);
            var loggingChannelId = storage.GetNamedID(type.LoggingChannelName);

            if (ConfessionModule.IsValidChannelId(publishChannelId))
            {
                await ConfessionModule.PublishConfessionAsync(embed, guild, publishChannelId);

                if (ConfessionModule.IsValidChannelId(loggingChannelId))
                {
                    await this.LogConfessionAsync(embed, guild, loggingChannelId);
                }
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 private async Task SendServerListAsync(SocketGuild[] guilds)
 {
     await this.ReplyAsync(ConfessionModule.ServerListText(guilds));
 }
Esempio n. 6
0
 private async Task <int> GetChoiceFromUserAsync()
 {
     return(ConfessionModule.ParseChoice(await this.NextMessageAsync()));
 }