Exemple #1
0
        public async Task AddServerInfoAsync()
        {
            var response = await DynamoSystem.QueryItemAsync <GuildInfo>("GuildName", QueryOperator.Equal, this.Context.Guild.Name)
                           .ConfigureAwait(false);

            if (response.Count < 1)
            {
                var existsResponse = EmbedHandler.GenerateEmbedResponse(
                    "This server already exists in the DB",
                    Color.Teal);
                await this.ReplyAsync("", false, existsResponse).ConfigureAwait(false);

                return;
            }

            var item = new GuildInfo
            {
                GuildGuid = this.Context.Guild.Id.ToString(),
                GuildName = this.Context.Guild.Name
            };
            await DynamoSystem.PutItemAsync(item).ConfigureAwait(false);

            var addedResponse = EmbedHandler.GenerateEmbedResponse(
                "This server has been added to the DB",
                Color.Green);

            await this.ReplyAsync("", false, addedResponse).ConfigureAwait(false);
        }
Exemple #2
0
        public async Task ServerInfoAsync([Remainder] string name)
        {
            var response = await DynamoSystem.QueryItemAsync <GuildInfo>("GuildName", QueryOperator.Equal, name)
                           .ConfigureAwait(false);

            Embed embed;

            if (response.Count < 1)
            {
                embed = EmbedHandler.GenerateEmbedResponse(
                    "No servers were found with that name",
                    Color.Orange);
            }
            else
            {
                var message = response.Aggregate("Found the following servers:\r\n",
                                                 (current, guildInfo) =>
                                                 current + $"GuildGuid: {guildInfo.GuildGuid}\r\n" +
                                                 $"GuildName: {guildInfo.GuildName}\r\n\r\n");

                embed = EmbedHandler.GenerateEmbedResponse(
                    message);
            }

            await this.ReplyAsync("", false, embed).ConfigureAwait(false);
        }