private void CreateMemeCommand(string trigger, MemeTemplate template, ModuleBuilder module) { module.AddCommand(trigger, CommandCallbackAsync, command => { command .WithName(template.Name) .WithSummary(template.Description); AddParameters(template, command); }); }
private void CreateMemeDebugCommand(string trigger, MemeTemplate template, ModuleBuilder module) { module.AddCommand(trigger, DebugCommandCallbackAsync, command => { command .WithName($"{template.Name} (Debug)") .WithSummary(template.Description) .AddPrecondition(new RequireOwnerAttribute()); AddParameters(template, command); }); }
private static void AddParameters(MemeTemplate template, CommandBuilder command) { // TODO: Handle variadic arguments // TODO: Handle optional arguments // TODO: Handle default arguments if (template.InputFields.Count == 1) { var field = template.InputFields.First(); command.AddParameter <string>(field.Name, builder => { builder .WithSummary(field.Description) .WithIsRemainder(true); }); } else { foreach (var field in template.InputFields) { command.AddParameter <string>(field.Name, builder => { builder.WithSummary(field.Description); }); } } }
public MemeGeneratorService AddTemplate(string commandAlias, MemeTemplate template) { _commandAliasToTemplates[commandAlias] = template; _commandNameToTemplates[template.Name] = template; return(this); }