r-Techsupport / TuringBot

A scaleable Discord bot, built as a replacement for https://github.com/r-Techsupport/TechSupportBot
GNU Affero General Public License v3.0
1 stars 3 forks source link

Logger doesn't respect the channel is not being set #50

Open Cpt-Dingus opened 1 year ago

Cpt-Dingus commented 1 year ago

The code and warning suggests there should be an early return should be present here


    // silence all logging channel event messages if an ID has not been set,
    // yet an attempt is still being made to log something
    if (loggingChannelId === '' && loggingLevel !== 0) {
      botConfig.logging.loggingChannel.verboseLevel = 0;
      logEvent(
        EventCategory.Warning,
        'core',
        'No logging channel ID has been set, to prevent this warning, set `logging.loggingChannel.verboseLevel` to 0 in the config. Logging through discord will be disabled until restart.',
        1
      );
    }
    // Sending the event to the logging channel
    if (loggingLevel >= verbosity) {
      /**
       * The actual {@link TextChannel} discord.js reference to the
       * event channel
       */
      const loggingChannel: TextChannel = client.channels.cache.get(
        loggingChannelId
      ) as TextChannel;

      void loggingChannel.send({embeds: [eventEmbed]});
    }```