src/command_meta/discord-channels-arg.js
/**
   * Validates that all given channels are existing for the organization and have a proper type (text, voice etc.).
   * @see OrgChannel
   * @param  {Context}          context     the Bot's context
   * @param  {string}           orgId       the organization identifier
   * @param  {string}           channelType the channel type
   * @return {Promise<Boolean>}             true if the validation passed
   */
Validates that all given channels are existing for the organization and have a proper type (text, voice etc.).
Validates that all given channels are existing for the organization and have a proper type ( text voice etc . ) .
async validateDiscordChannelsArg(context, orgId, channelType) {
    if (this.channels.length === 0) {
      return false;
    }
    const orArray = [];
    for (let i = 0; i < this.channels.length; i++) {
      orArray.push({ id: this.channels[i] });
    }
    const query = { $or: orArray };
    if (channelType !== undefined) {
      query.type = channelType;
    }
    const channelRows = await context.dbManager.getDiscordRows(context.dbManager.channelsTable, orgId, query);
    return channelRows.length !== this.channels.length;
  }
async validateDiscordChannelsArg ( context , orgId , channelType ) { if ( this . channels . length === 0 ) { return false ; } const orArray = [ ] ; for ( let i = 0 ; i < this . channels . length ; i ++ ) { orArray . push ( { id : this . channels [ i ] } ) ; } const query = { $or : orArray } ; if ( channelType !== undefined ) { query . type = channelType ; } const channelRows = await context . dbManager . getDiscordRows ( context . dbManager . channelsTable , orgId , query ) ; return channelRows . length !== this . channels . length ; }
Validates that all given channels are existing for the organization and have a proper type (text, voice etc.).
Validates that all given channels are existing for the organization and have a proper type ( text voice etc . ) .