mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Disable commands if env vars are missing
This commit is contained in:
@@ -103,6 +103,48 @@ client.on('ready', async () => {
|
||||
client.logger.error(`[DISABLED] Error while disabling commands:\n${err.stack}`);
|
||||
}
|
||||
|
||||
// Check for API keys and disable commands that need them if not present
|
||||
if (!process.env.REDIS_HOST || !process.env.REDIS_PASS) {
|
||||
client.logger.error('[REDIS] No REDIS_HOST or REDIS_PASS in env. Exiting process.');
|
||||
process.exit(1);
|
||||
}
|
||||
if (!process.env.BITLY_KEY) {
|
||||
client.registry.commands.get('shorten-url').disable();
|
||||
client.logger.info('[DISABLED] No BITLY_KEY in env. shorten-url has been disabled.');
|
||||
}
|
||||
if (!process.env.CLEVERBOT_KEY) {
|
||||
client.registry.commands.get('cleverbot').disable();
|
||||
client.registry.commands.get('cleverbot-end').disable();
|
||||
client.logger.info('[DISABLED] No CLEVERBOT_KEY in env. cleverbot and cleverbot-end have been disabled.');
|
||||
}
|
||||
if (!process.env.GITHUB_ACCESS_TOKEN) {
|
||||
client.registry.commands.get('github').disable();
|
||||
client.registry.commands.get('changelog').disable();
|
||||
client.logger.info('[DISABLED] No GITHUB_ACCESS_TOKEN in env. github and changelog have been disabled.');
|
||||
}
|
||||
if (!process.env.GOV_KEY) {
|
||||
client.registry.commands.get('apod').disable();
|
||||
client.logger.info('[DISABLED] No GOV_KEY in env. apod has been disabled.');
|
||||
}
|
||||
if (!process.env.SPOTIFY_KEY || !process.env.SPOTIFY_SECRET) {
|
||||
client.registry.commands.get('guess-song').disable();
|
||||
client.logger.info('[DISABLED] No SPOTIFY_KEY or SPOTIFY_SECRET in env. guess-song has been disabled.');
|
||||
}
|
||||
if (!process.env.THECATAPI_KEY) {
|
||||
client.registry.commands.get('cat').disable();
|
||||
client.logger.info('[DISABLED] No THECATAPI_KEY in env. cat has been disabled.');
|
||||
}
|
||||
if (!process.env.THEDOGAPI_KEY) {
|
||||
client.registry.commands.get('dog').disable();
|
||||
client.logger.info('[DISABLED] No THEDOGAPI_KEY in env. dog has been disabled.');
|
||||
}
|
||||
if (!process.env.WEBSTER_KEY) {
|
||||
client.registry.commands.get('word-of-the-day').disable();
|
||||
client.registry.commands.get('word-chain').disable();
|
||||
client.registry.commands.get('define').disable();
|
||||
client.logger.info('[DISABLED] No WEBSTER_KEY in env. word-of-the-day, word-chain, and define have been disabled.');
|
||||
}
|
||||
|
||||
// Import command-last-run.json
|
||||
try {
|
||||
const results = client.importLastRun();
|
||||
|
||||
@@ -82,7 +82,7 @@ module.exports = class HangmanCommand extends Command {
|
||||
points++;
|
||||
}
|
||||
}
|
||||
const defined = await this.defineWord(word);
|
||||
const defined = WEBSTER_KEY ? await this.defineWord(word) : null;
|
||||
if (word.length === confirmation.length || guessed) {
|
||||
return msg.say(stripIndents`
|
||||
You won, it was ${word}!
|
||||
|
||||
@@ -52,6 +52,7 @@ module.exports = class XiaoCommand extends Command {
|
||||
else if (site === 'deviant') result = `Art by <https://www.deviantart.com/${source[2]}>`;
|
||||
else if (site === 'pixiv') result = `Art Source: <https://www.pixiv.net/en/artworks/${source[2]}>`;
|
||||
else result = `Art by ${site}`;
|
||||
if (!SAUCENAO_KEY) return result;
|
||||
try {
|
||||
const data = await this.sauceNao(img);
|
||||
if (data && data[0].similarity > 90) {
|
||||
|
||||
@@ -62,6 +62,7 @@ module.exports = class PlayCommand extends Command {
|
||||
async searchForVideo(query, nsfw) {
|
||||
if (ytdl.validateURL(query)) return ytdl.getURLVideoID(query);
|
||||
if (ytdl.validateID(query)) return query;
|
||||
if (!GOOGLE_KEY) return null;
|
||||
const { body } = await request
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
|
||||
Reference in New Issue
Block a user