Skip to content

Commit

Permalink
Added a command deployer script.
Browse files Browse the repository at this point in the history
  • Loading branch information
moonstar-x committed Jan 19, 2022
1 parent 4dd3008 commit aca6352
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"debug": "node ./src/app.js --debug",
"dev": "nodemon --exec npm start",
"lint:errors-only": "node_modules/.bin/eslint src --quiet",
"lint": "node_modules/.bin/eslint src"
"lint": "node_modules/.bin/eslint src",
"deploy": "node ./src/command-deployer.js"
},
"engines": {
"node": ">=16.6"
Expand Down
48 changes: 48 additions & 0 deletions src/command-deployer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const path = require('path');
const { ExtendedClient, ConfigProvider } = require('@greencoast/discord.js-extended');
const logger = require('@greencoast/logger');

const config = new ConfigProvider({
env: process.env,
configPath: path.join(__dirname, '../config/settings.json'),
types: {
TOKEN: 'string'
}
});

const client = new ExtendedClient({
config,
intents: []
});

client.registry
.registerGroups([
['all-tts', 'All TTS Commands'],
['config', 'Configuration Commands'],
['google-tts', 'Google TTS Commands'],
['other-tts', 'Other TTS Commands'],
['misc', 'Miscellaneous Commands']
])
.registerCommandsIn(path.join(__dirname, './commands'));

client.on('ready', async() => {
try {
client.deployer.rest.setToken(config.get('TOKEN'));
await client.deployer.deployGlobally();
} catch (error) {
logger.error('Something happened when trying to deploy the commands globally.', error);
process.exit(1);
}
});

client.on('commandsDeployed', (commands) => {
commands.forEach((command) => {
logger.info(`Successfully deployed ${command.name} command globally!`);
});

logger.info(`Finished deploying ${commands.length} commands globally. These changes can take up to an hour to be reflected on Discord.`);

process.exit(0);
});

client.login(config.get('TOKEN'));

0 comments on commit aca6352

Please sign in to comment.