src/commands_discord/image/add-image-template-command.js
/**
   * Executes the command instance. The main function of a command, it's essence.
   * All arguments scanning, validation and permissions check is considered done before entering this function.
   * So if any exception happens inside the function, it's considered a Bot's internal problem.
   * @param  {BaseMessage}         message the Discord message as the source of the command
   * @return {Promise<string>}             the result text to be replied as the response of the execution
   */
Executes the command instance. The main function of a command, it's essence.
All arguments scanning, validation and permissions check is considered done before entering this function.
So if any exception happens inside the function, it's considered a Bot's internal problem.
@param  {BaseMessage}         message the Discord message as the source of the command
@return {Promise}             the result text to be replied as the response of the execution
Executes the command instance . The main function of a command it ' s essence . All arguments scanning validation and permissions check is considered done before entering this function . So if any exception happens inside the function it ' s considered a Bot ' s internal problem . @param { BaseMessage } message the Discord message as the source of the command @return { Promise } the result text to be replied as the response of the execution
async executeForDiscord(message) {
    const existingTemplates = await this.context.dbManager.getDiscordRows(
      this.context.dbManager.imageTemplateTable,
      this.orgId,
      {});
    if (existingTemplates.length >= this.context.prefsManager.max_image_templates_per_discord_org) {
      return this.langManager.getString(
        'command_addimagetemplate_too_many_image_templates',
        this.context.prefsManager.max_image_templates_per_discord_org
      );
    }
    const template = {
      id: this.templateName,
      orgId: this.orgId,
      source: this.source,
      config: JSON.parse(this.jsonConfig)
    };
    const res = await this.context.dbManager.insertOne(this.context.dbManager.imageTemplateTable, template);
    if (res) {
      return this.langManager.getString(
        'command_addimagetemplate_success',
        this.templateName
      );
    } else {
      return this.langManager.getString(
        'command_addimagetemplate_error_not_unique_name',
        this.templateName
      );
    }
  }
async executeForDiscord ( message ) { const existingTemplates = await this . context . dbManager . getDiscordRows ( this . context . dbManager . imageTemplateTable , this . orgId , { } ) ; if ( existingTemplates . length >= this . context . prefsManager . max_image_templates_per_discord_org ) { return this . langManager . getString ( 'command_addimagetemplate_too_many_image_templates' , this . context . prefsManager . max_image_templates_per_discord_org ) ; } const template = { id : this . templateName , orgId : this . orgId , source : this . source , config : JSON . parse ( this . jsonConfig ) } ; const res = await this . context . dbManager . insertOne ( this . context . dbManager . imageTemplateTable , template ) ; if ( res ) { return this . langManager . getString ( 'command_addimagetemplate_success' , this . templateName ) ; } else { return this . langManager . getString ( 'command_addimagetemplate_error_not_unique_name' , this . templateName ) ; } }
Executes the command instance.
Executes the command instance .
// Inherited function with various possible implementations, some args may be unused. /* eslint no-unused-vars: ["error", { "args": "none" }] */