Rostcraft
Rostcraft

Reputation: 5

How to reply to messages in discord with python requests?

I need to reply to the message. But my code prints this: {"code": 50035, "errors": {"message_reference": {"_errors": [{"code": "MODEL_TYPE_CONVERT", "message": "Only dictionaries may be used in a ModelType"}]}}, "message": "Invalid Form Body"}

import requests
url = "https://discord.com/api/v8/channels/{}/messages".format(channel_id)
data = {"content": "oof",'message_reference': {'channel_id': channel_id, 'message_id': message_id}}
header = {"authorization": token}
r = requests.post(url, data=data, headers=header)
print(r.text)

And I definitely don't want to use discord.py

Upvotes: 0

Views: 1098

Answers (1)

Koll
Koll

Reputation: 142

Code is right, but you have to use json parameter instead of data parameter

r = requests.post(url, json=data, headers=header)

Upvotes: 1

Related Questions