コード例 #1
0
        public async Task TagInfoCommand(string tagName)
        {
            var errorEmbed   = new EmbedBuilder();
            var embedBuilder = new EmbedBuilder();

            if (TagService.GetIfTagExists(tagName))
            {
                foreach (var tag in TagService.GetTag(tagName))
                {
                    embedBuilder.WithTitle(tag.Name);
                    embedBuilder.WithDescription(
                        $"**Created By**\n {Context.Client.GetUser(tag.OwnerId).Mention}\n\n **Uses** \n{TagService.GetUsesForTag(tagName)}");
                    embedBuilder.WithColor(Color.DarkGreen);
                    embedBuilder.WithAuthor($"{Context.User.Username}#{Context.User.Discriminator}",
                                            Context.Client.GetUser(tag.OwnerId).GetAvatarUrl());
                    embedBuilder.WithFooter("Tag created at ");
                    embedBuilder.WithTimestamp(DateTimeOffset.FromUnixTimeSeconds(tag.CreatedAt));
                }

                await ReplyAsync("", false, embedBuilder.Build());
            }
            else
            {
                errorEmbed.WithTitle("Error!");
                errorEmbed.WithDescription($"Tag '**{tagName}**' doesn't exists");
                errorEmbed.WithColor(Color.Red);
                await ReplyAsync("", false, errorEmbed.Build());
            }
        }
コード例 #2
0
        public async Task TagGetCommand(string tagName)
        {
            var embed = new EmbedBuilder();

            if (TagService.GetIfTagExists(tagName))
            {
                await TagService.IncreaseUsesForTag(tagName);

                embed.WithFooter($"Requested by {Context.User.Username}");
                embed.WithCurrentTimestamp();
                embed.WithColor(Color.DarkBlue);
                await ReplyAsync(TagService.GetTagContentByName(tagName), false, embed.Build());

                await Context.Message.DeleteAsync();
            }
            else
            {
                embed.WithTitle("Error!");
                embed.WithDescription($"Tag '**{tagName}**' doesn't exist");
                embed.WithColor(Color.Red);
                embed.WithFooter("Requested by " + Context.User.Username);
                await ReplyAsync("", false, embed.Build());

                await Context.Message.DeleteAsync();
            }
        }
コード例 #3
0
            public async Task TagEditCommand(string tagName, [Remainder] string tagNewContent)
            {
                var embed = new EmbedBuilder();

                if (TagService.GetIfTagExists(tagName))
                {
                    await TagService.EditTag(tagName, tagNewContent);

                    embed.WithTitle("Success!");
                    embed.WithDescription($"Tag '**{tagName}**' was successfully edited");
                    embed.WithColor(Color.DarkGreen);
                }
                else
                {
                    embed.WithTitle("Error!");
                    embed.WithDescription($"Tag '**{tagName}**' doesn't exists");
                    embed.WithColor(Color.Red);
                }

                await ReplyAsync("", false, embed.Build());
            }
コード例 #4
0
            public async Task TagCreateCommand(string tagName, [Remainder] string tagContent)
            {
                var embed = new EmbedBuilder();

                if (!TagService.GetIfTagExists(tagName))
                {
                    await TagService.CreateTag(tagName, tagContent, Context.User.Username, Context.User.Id);

                    embed.WithTitle("Success!");
                    embed.WithDescription($"Tag '**{tagName}**' was successfully created");
                    embed.WithColor(Color.DarkGreen);
                }
                else
                {
                    embed.WithTitle("Error!");
                    embed.WithDescription($"Tag '**{tagName}**' already exists");
                    embed.WithColor(Color.Red);
                }

                await ReplyAsync("", false, embed.Build());
            }
コード例 #5
0
            public async Task TagDeleteCommand(string tagName)
            {
                var embed = new EmbedBuilder();

                if (TagService.GetIfTagExists(tagName))
                {
                    await TagService.DeleteTagByName(tagName);

                    embed.WithTitle("Success!");
                    embed.WithDescription($"Tag '**{tagName}**' was successfully deleted");
                    embed.WithColor(Color.DarkGreen);
                    embed.WithCurrentTimestamp();
                }
                else
                {
                    embed.WithTitle("Error!");
                    embed.WithDescription($"Tag '**{tagName}**' doesn't exists");
                    embed.WithColor(Color.Red);
                    embed.WithCurrentTimestamp();
                }

                await ReplyAsync("", false, embed.Build());
            }