Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Google: QOL changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpt-Dingus committed Aug 15, 2023
1 parent 4158506 commit 1bff8a7
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/modules/google.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/**
* @file This file contains the 'google' and 'youtube' module definitions
* @file
* Modules:
* - {@link googleModule}
* - Submodules: Search, image
* - {@link youtube}
*/

import {APIEmbed, BaseMessageOptions, Colors} from 'discord.js';
Expand All @@ -13,7 +17,7 @@ const youtubeSearch = google.youtube('v3'); // 10k/day limit
const GOOGLE_ICON_URL =
'https://cdn.icon-icons.com/icons2/673/PNG/512/Google_icon-icons.com_60497.png';

/** The root google command definition */
/** The root Google module definition */
const googleModule = new util.RootModule(
'google',
'Manages google commands',
Expand Down Expand Up @@ -41,6 +45,13 @@ googleModule.registerSubModule(
[undefined, ''].includes(API_KEY) ||
[undefined, ''].includes(CSE_ID)
) {
util.logEvent(
util.EventCategory.Warning,
'google',
'Config error: The API key / CSE id is not set!',
1
);

return util.embed.errorEmbed(
'Config error: The API key / CSE id is not set!'
);
Expand Down Expand Up @@ -99,6 +110,12 @@ googleModule.registerSubModule(
[undefined, ''].includes(API_KEY) ||
[undefined, ''].includes(CSE_ID)
) {
util.logEvent(
util.EventCategory.Warning,
'google',
'Config error: The API key / CSE id is not set!',
1
);
return util.embed.errorEmbed(
'Config error: The API key / CSE id is not set!'
);
Expand Down Expand Up @@ -129,7 +146,7 @@ googleModule.registerSubModule(
)
);

/** The root Google module definition */
/** The root Youtube module definition */
const youtube = new util.RootModule(
'youtube',
'Searches youtube videos based on a query',
Expand All @@ -146,6 +163,12 @@ const youtube = new util.RootModule(
const API_KEY: string | undefined = googleModule.config.ApiKey;

if ([undefined, ''].includes(API_KEY)) {
util.logEvent(
util.EventCategory.Warning,
'google',
'Config error: The API key is not set!',
1
);
return util.embed.errorEmbed(
'Config error: The Google API key is not set!'
);
Expand Down

0 comments on commit 1bff8a7

Please sign in to comment.