This Discord bot was developed with Node JS to practice programming and testing bot functions in Discord. The bot is currently equipped with a simple slash command that responds to the /ping command with "Pong". More slash commands are needed to realize the full potential of the bot.
The challenge is to program another 'slash' command within 30 minutes. If the command works, create a pull request. So get started and expand the bot according to your ideas. I look forward to your ideas.
To create a new slash command, you need to follow these steps:
-
Create a new file in the
commands
directory. The filename should correspond to the command you want to create (e.g.,mycommand.js
). -
In this file, you need to export an object that has the properties
name
,description
, andexecute
.name
is the name of the command,description
is a brief description of what the command does, andexecute
is a function that is called when the command is executed.
Here is an example:
module.exports = {
name: 'mycommand',
description: 'This is my new command',
execute(interaction) {
interaction.reply('This is the response of my command');
},
};
Command | Description | Usage |
---|---|---|
... | ... | ... |
/randomname | Generates a random funny name. | /randomname |
/mystery | Sends a little encouragement. Responds with "a secret note" when called. | /mystery |
/funnypic | Responds with a random Imgur image | /funnypic |
/timer | Starts, stops, or checks a timer. /timer start starts the timer, /timer stop stops the timer and displays the elapsed time. |
/timer start , /timer stop |
/ping | Responds with "Pong". This is a simple test command to check if the bot is responding. | /ping |
/user | Returns information about the calling user. Depending on the implementation, this can include the username, ID, role, and other relevant information. | /user |