예제 #1
0
        public static async Task AddGlobalTagsAsync <T>(
            EspeonDbContext context,
            ICommandService commandService,
            ILogger <T> logger)
        {
            logger.LogInformation("Adding global tags");
            await context.GlobalTags.LoadAsync();

            commandService.AddModule <TagModule>(moduleBuilder => {
                foreach (var tag in context.GlobalTags)
                {
                    logger.LogDebug("Adding global tag {name}", tag.Key);
                    moduleBuilder.AddCommand(
                        context => GlobalTagCallbackAsync((EspeonCommandContext)context),
                        commandBuilder => commandBuilder.WithName(tag.Key).Aliases.Add(tag.Key));
                }

                logger.LogDebug("Created global tag module");
            });
        }