add checks for config.json
Marco Andronaco andronacomarco@gmail.com
Thu, 15 Sep 2022 23:39:33 +0200
3 files changed,
10 insertions(+),
1 deletions(-)
M
index.js
→
index.js
@@ -22,6 +22,7 @@ { activity: ActivityType.Competing, subject: 'prato fiorito' }, // in competizione su prato fiorito
{ activity: ActivityType.Watching, subject: 'i bambini' }, { activity: ActivityType.Playing, subject: 'quel gioco là non mi viene il titolo' }, + { activity: ActivityType.Playing, subject: 'mosca cieca in autostrada' }, { activity: ActivityType.Competing, subject: 'cacata ranked al cesso pubblico' }, ];@@ -48,5 +49,8 @@ console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); } }); + +if (!token) + throw 'Check your config.json!'; client.login(token);
M
tools/delete-commands.js
→
tools/delete-commands.js
@@ -3,8 +3,10 @@ const { Routes } = require('discord.js');
const { REST } = require('@discordjs/rest'); const { clientId, guildId, token } = require(path.join(process.cwd(), 'config.json')); -const rest = new REST({ version: '10' }).setToken(token); +if (!(clientId && guildId && token)) + throw 'Check your config.json!'; +const rest = new REST({ version: '10' }).setToken(token); // for guild-based commands rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] }) .then(() => console.log('Successfully deleted all guild commands.'))
M
tools/deploy-commands.js
→
tools/deploy-commands.js
@@ -4,6 +4,9 @@ const { Routes } = require('discord.js');
const { REST } = require('@discordjs/rest'); const { clientId, token } = require(path.join(process.cwd(), 'config.json')); +if (!(clientId && token)) + throw 'Check your config.json!'; + const commands = new Array(); const commandsPath = path.join(process.cwd(), 'commands'); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));