-
-
Save ianklatzco/769d9e3a991dc2f443a2e105b0157117 to your computer and use it in GitHub Desktop.
# post a message to discord api via a bot | |
# bot must be added to the server and have write access to the channel | |
# you may need to connect with a websocket the first time you run the bot | |
# use a library like discord.py to do so | |
import requests | |
import json | |
channelID = "your_id_goes_here" # enable dev mode on discord, right-click on the channel, copy ID | |
botToken = "your_token_here" # get from the bot page. must be a bot, not a discord app | |
baseURL = "https://discordapp.com/api/channels/{}/messages".format(channelID) | |
headers = { "Authorization":"Bot {}".format(botToken), | |
"User-Agent":"myBotThing (http://some.url, v0.1)", | |
"Content-Type":"application/json", } | |
message = "hello world" | |
POSTedJSON = json.dumps ( {"content":message} ) | |
r = requests.post(baseURL, headers = headers, data = POSTedJSON) |
Can someone do the same with node.js ?
How to read messages on a date from a channel?. Could someone post a sample get request using a webhook? Sorry newbie here
Can someone do the same with node.js ?
please use Axios. its the same.
May I know how to send embedded message from JSON? What to put in the content? Can you help me up?
https://anidiotsguide.gitbooks.io/discord-js-bot-guide/examples/using-embeds-in-messages.html
Maybe this will be useful
https://leovoel.github.io/embed-visualizer/
How to add role or remove ?
Bot token must be specified with a bot in the beginning of the string. Example: Authorization: Bot MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kKWs
How to send with this some commands with slash '/'?
nice and simple, perfect.
I'm just getting 405 method forbidden using Postman
Nvm I had forgotten the last part of the endpoint
this is such an expensive code displayed humbly