DEV Community

Cover image for [Discord] Send message through Bot
nicha
nicha

Posted on

[Discord] Send message through Bot

I am a newbie to Discord. Recently, my friend and I started a discord channel for a live talk session to interview people and share our experiences with interested people.

When sending a message, I'm thinking about a way to send a message through a bot instead of using my account, so my friend taught me a way to do that. And today, you will know it too!!



First of all, you have to be an admin of that server. Then, visit the server setting > integration > webhook.

Webhook-setting

Then, click "New Webhook" and choose the channel that you want to send message to
Create-webhook

Later on, click on the button "Copy Webhook URL" to copy the webhook URL

Lastly, you can send a message by inputting it into the curl.

curl --location --request POST '{YOUR_WEBHOOK_URL}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": "{YOUR_MESSAGE}",
    "username": "{SENDER_NAME}",
    "avatar_url": "{PICTURE_URL}"
}
'
Enter fullscreen mode Exit fullscreen mode

Please feel free to share interesting bot and command in discord with me 👾

Top comments (1)

Collapse
 
thomasbnt profile image
Thomas Bnt ☕

Hello nice post about Discord and Curl!

Don't hesitate to put colors on your codeblock like this example for have to have a better understanding of your code 😎

console.log('Hello world!');
Enter fullscreen mode Exit fullscreen mode

Example of how to add colors and syntax in codeblocks