Skip to content

Instantly share code, notes, and snippets.

@ianklatzco
Created December 29, 2016 02:36
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save ianklatzco/c033b33757915feaf48fd0caf14b42cb to your computer and use it in GitHub Desktop.
Save ianklatzco/c033b33757915feaf48fd0caf14b42cb to your computer and use it in GitHub Desktop.
sends a message to a discord channel via a bot using command line HTTP POST- curl
#!/bin/bash
# update the TOKEN and the CHANNELID, rest is optional
# you may need to connect with a websocket the first time you run the bot
# use a library like discord.py to do so
curl -v \
-H "Authorization: Bot TOKEN" \
-H "User-Agent: myBotThing (http://some.url, v0.1)" \
-H "Content-Type: application/json" \
-X POST \
-d '{"content":"Posting as a bot"}' \
https://discordapp.com/api/channels/CHANNELID/messages
@j-l-s
Copy link

j-l-s commented Mar 20, 2020

Thanks for the script.

A way to get the channel URL is to create and use a discord's webhook:

@k1msho
Copy link

k1msho commented May 14, 2020

How i get the channel id url?

@Justintime50
Copy link

@k1msho In The Discord application go to Settings > Appearance > Check developer mode. Right click channel name and copy the channel ID (Copy ID).

@celik23
Copy link

celik23 commented Mar 17, 2024

tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment