コード例 #1
0
 private void CreateMemeCommand(string trigger, MemeTemplate template, ModuleBuilder module)
 {
     module.AddCommand(trigger, CommandCallbackAsync, command =>
     {
         command
         .WithName(template.Name)
         .WithSummary(template.Description);
         AddParameters(template, command);
     });
 }
コード例 #2
0
 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);
     });
 }
コード例 #3
0
 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); });
         }
     }
 }
コード例 #4
0
 public MemeGeneratorService AddTemplate(string commandAlias, MemeTemplate template)
 {
     _commandAliasToTemplates[commandAlias] = template;
     _commandNameToTemplates[template.Name] = template;
     return(this);
 }