all repos — simple-discord-music-bot @ 150cab4bd1dd3d852b5e00f38fd890fc95923c63

A Discord bot making use of discord.js and play-yt.

add checks for config.json
Marco Andronaco andronacomarco@gmail.com
Thu, 15 Sep 2022 23:39:33 +0200
commit

150cab4bd1dd3d852b5e00f38fd890fc95923c63

parent

97d143480c5e930b650d03144851f59a790715c6

3 files changed, 10 insertions(+), 1 deletions(-)

jump to
M index.jsindex.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.jstools/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.jstools/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'));