This is a WAHT Discord chatbot project developed by Metabon. The chatbot is designed to allow users to check and RSVP for events using Discord, even if they do not use the waht.app application. This is built using Node.js, Express.js, Discord.js, etc. To use this Chatbot, both the API module and the Chatbot module are required.
The chatbot provides the following key features(slash commands):
/waht check
: Checks if the user has used this Discord chatbot before, and if not, retrieves the user's NFT record using a QR code./waht refresh
: If there has been any change in the user's NFT record, this command can be used to update the user's NFT record./waht events
: Based on the user's NFT, this command shows a list of events that the user can attend. Users can also check the detailed information of each event./waht rsvp
: Users can RSVP for events, and a QR code is generated accordingly. Users can also cancel their event reservations.
These are the instructions for setting up the chatbot project locally. To run the chatbot on your local machine, follow these simple steps:
- To create a bot, go to Discord Developer Portal and click on [New Application] on the top right corner.
- Enter the name for the application you want to create and click on [Create].
- After the application is created, click on 'Bot' on the left-hand side menu, and then click on [Add Bot].
- Click on [Yes, do it!] to confirm adding the bot.
- Make sure to enable all three options (PRESENCE INTENT, SERVER MEMBERS INTENT, MESSAGE CONTENT INTENT) in the Privileged Gateway Intents section.
- Copy and save the token of the created bot. This token will be managed in the environment variables of the code later on.
- Click on OAuth2 on the left-hand side menu, and then copy and save the Client ID. This ID will also be managed in the environment variables of the code later on.
- On the left-hand menu, go to OAuth2 > General and set it up as follows:
- On OAuth2 > URL Generator, set it up as follows:
- Copy the generated URL at the bottom, and paste it into your browser. This will open an authorization window to connect the chatbot to a server.
- After permission is granted you can see that the bot account is listed as offline in the user list within your Discord application.
- Create a .env file in the root directory of the project.
- Copy the following variables to the .env file and replace the placeholder values with your own:
TYPEORM_TYPE=YOUR_DATABASE_CONNECTION
TYPEORM_HOST=YOUR_HOST_NUMBER
TYPEORM_USERNAME=YOUR_USERNAME
TYPEORM_PASSWORD=YOUR_PASSWORD
TYPEORM_DATABASE=YOUR_DB
TYPEORM_TIMEZONE=TIMEZONE
TYPEORM_DATESTRINGS=TRUE
TYPEORM_LOGGING=LOGGING
PORT=YOUR_PORT_NUMBER
ALCHEMY_API_KEY=YOUR_ALCHEMY_API_KEY
- Save the .env file.
- Create a .env file in the root directory of the project.
- Copy the following variables to the .env file and replace the placeholder values with your own:
CLIENT_ID=YOUR_DISCORD_CLIENT_ID
TOKEN=YOUR_DISCORD_TOKEN
ALCHEMY_API_KEY=YOUR_ALCHEMY_API_KEY
SERVER_URL=YOUR_SERVER_URL
WAHT_IMAGE=IMAGE_URL
- Save the .env file.
Note: Make sure to keep the .env file private and not share it with anyone, as it contains sensitive information.
Node.js 16.9.0 or latest version is required. Use the package manager npm to install.
npm install
- Before starting the chatbot, register slash commands in discord channel by running
node deploy-commands.js
. (This process only needs 1 time.) (If you want to erase all the registered commands, runnode delete-all-commands.js
) - Start both the chatbot and API by running
npm start
. - Once both are running, check that the chatbot is online in your Discord server.
- Type a slash command in the chat, such as
/ping
, to activate the bot and trigger the command. - The following slash commands can be used in this chatbot: