Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 6, 2022 04:41 pm GMT

Discord Bot with Slash Commands, Node.js, and Typescript deployable to Heroku

Guide

A setup guide can be found in the README of the repo:
Discord-Node-Typescript-Template

Summary

While learning how to create a Discord bot, I decided it would be good practice to save and document a boilerplate for the Discord bot setup I had going. I wanted to use strict imports and typescript, and I figured others may too. I also wanted to utilize Slash commands. I was inspired by another blog that I cannot find, but the blog stopped at local development, and there were a few quirks to getting it to deploy on Heroku.

The main script is wrapped in an instantly called async function to enable top level await, and the template is configured with ENV variables.

To deploy to Heroku, the Procfile (without an extension) must exist in your repository with contents:

worker: npm start

Limitations - Version 1.0

Current implementation can only be used for 1 Discord server per bot as GUILD_ID is taken as an environment variable. I will update the repo when another approach is taken.

Let me know if this is helpful or you have any feeback, thanks!


Original Link: https://dev.to/arfemia/discord-bot-with-nodejs-and-typescript-deployable-to-heroku-360i

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To