- In this GitHub repository page, use the button Use this template to create a GitHub repo under your account.
- Clone that new repository you craeted to your local computer:
git clone https://github.com/P026/<repo_name>
, replace<repo_name>
with your repo name. - Change directory to the newly created directory (will have the same name as the repository) in your pc, use
cd <direcory_name>
(replace<directory_name>
with the actual name) - Install the dependencies: Use the command
npm install
oryarn
- Create command files inside the
src/commands
directory. Check the example commandping.js
for reference - Make sure the export object name matches the command name in the
SlashCommandBuilder.setName()
- You can even export multiple commands from a single file. Reference example is in
multiple.js
- Then, edit the
commands/index.js
file to re export everything from your created files. Use the syntaxexport * from './<filename>.js'
for each file. Replace<filename>
with the name of the files you created. - In the registering step, when you register the commands, only commands that are exported from this
commands/index.js
file will be registered and if a previous command is not exported from there, it will be unregistered/deleted.
- Create a file named
.env
in the root of the project. - put these variables in that file
TOKEN=<bot token>
CLIENT_ID=<application or bot client id>
GUILD_ID=<required if you wanna register commands for a guild>
npm run register
# or
yarn register
This will add any commands exported from the commands/index.js
file and/or remove any commands that are not exported.
npm run guildregister
# or
yarn guildregister
This will add any commands exported from the commands/index.js
file and/or remove any commands that are not exported.
The effect is only on the particular server, id of which is available as the GUILD_ID
environment variable.
npm run dev
# or
yarn dev
- Use Heroku GitHub integration to deploy
- Add and commit all your changes in the repository:
git add .
andgit commit -m "Commit message"
- Push to GitHub:
git push origin main
- Go to Heroku dashboard, create or use an existing Heroku app, go to the
deploy
tab and select GitHub as deployment method and follow further instructions there
- Install the heroku cli tool: Check this page for instructions https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli
- Login to the heroku cli using your Heroku account: Use the command
heroku login
- Create a Heroku app or add the remote url of an existing Heroku app to the project
- To create use this command:
heroku create <app_name>
. Replace<app_name>
with a name of your choice - Or to add the remote url of an existing app:
heroku git:remote -a <existing_heroku_app_name>
- To create use this command:
- Go to your Heroku dashboard in the Heroku website, and in your app's config vars settings, add the
TOKEN
key/environment variable along with the value as your discord bot's token - Add and commit your changes for files:
git add .
andgit commit -m "Commit message"
- Push to heroku remote repository:
git push heroku main
- Scale to worker instead of web process:
heroku ps:scale web=0 worker=1