Skip to content

Commit

Permalink
dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
rastiqdev committed Nov 5, 2021
1 parent 224a15d commit e300b73
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
config.json
.env
package-lock.json
.idea
*.iml
Expand Down
Empty file added config.json
Empty file.
6 changes: 3 additions & 3 deletions deploy-commands.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');
require('dotenv').config();

const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
Expand All @@ -11,8 +11,8 @@ for (const file of commandFiles) {
commands.push(command.data.toJSON());
}

const rest = new REST({ version: '9' }).setToken(token);
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
rest.put(Routes.applicationGuildCommands(process.env.CLIENTID, process.env.GUILDID), { body: commands })
.then(() => console.log('Commandes établies avec succès !'))
.catch(console.error);
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');
const { Client, Collection, Intents } = require('discord.js');
const { token } = require('./config.json');
require('dotenv').config();

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

Expand Down Expand Up @@ -31,4 +32,4 @@ client.on('interactionCreate', async interaction => {
}
});

client.login(token);
client.login(process.env.TOKEN);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"@discordjs/rest": "^0.1.0-canary.0",
"discord-api-types": "^0.24.0",
"discord.js": "^13.3.1"
"discord.js": "^13.3.1",
"dotenv": "^10.0.0"
}
}

0 comments on commit e300b73

Please sign in to comment.