To use Discord.js, you need to first install it using npm. Open your command prompt and run the following command:
index.tsx23 chars2 lines
Once it's installed, you can start coding your bot. Create a new JavaScript file and require the Discord.js library:
index.tsx76 chars3 lines
Discord.js uses an event-driven architecture, where you register event listeners for various events and respond accordingly. For example, the following code logs the bot in when it's ready:
index.tsx82 chars4 lines
You can also listen for events such as messages being sent:
index.tsx94 chars6 lines
Finally, you need to log your bot in with your Discord API token:
index.tsx38 chars2 lines
This is just a basic example to get you started. Discord.js has many more features, such as voice support, user mentions, and message attachments. Check out the Discord.js documentation for more information.
gistlibby LogSnag