Skip to content

Commit

Permalink
New Post: How to create discord bot?
Browse files Browse the repository at this point in the history
Merge pull request #10 from fredemerson/main
  • Loading branch information
Zemerik authored Oct 20, 2024
2 parents 93d4b23 + 6971506 commit b7d214e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/content/blog/how_to_create_discord_bot.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
layout: ../../layouts/BlogPost.astro
title: How to Create a Discord Bot?
description: Learn how to create a simple discord bot
pubDate: 10/20/2024
---

# How to Code a Discord bot?

## 💻STEP 1 - Setting up your workspace:

- Head over to the terminal of your project and type, `npm init` to set up a nodejs project.

## 😃Step 2 - Add the Code:

- Copy Paste the following code in your entry point,

```js
const express = require('express')
const Discord = require('discord.js')
const app = express();

app.listen(3000, () => {
console.log("Project is running!");
})

const client = new Discord.Client({ intents: 32767 }) 

client.on('messageCreate', async (message) => {
if (message.content === "hi") {
message.channel.send('helllo')
}
})

client.login('YOUR BOT TOKEN HERE')
```

- Remember to replace **YOUR BOT TOKEN HERE** with the actual token of your bot which can be obtained from [the developer portal](https://discord.com/developers/applications)

## 🥇Step 3 - Running your project

- You are now ready to run your project. As soon as your run your project, your discord bot should appear online and send `hello` whenever someone types `hi`.

0 comments on commit b7d214e

Please sign in to comment.