yurrickx_
yurrickx_

Reputation: 23

interact with discord using requests in python

I'm trying to automate clicking on discord buttons using requests and python, but i have an error when i send the request.

discord buttons

I tried this :

header = {
        'authorization' : 'XXX'
}    

data = {
        "type": 3,
        "guild_id": "XXX",
        "channel_id": "XXX",
        "message_id": message['id'],
        "application_id": "XXX",
        "data": {
                "component_type": 2,
                "custom_id": message['components'][0]['components'][1]['custom_id']
        }
}

try:
        r = requests.post('https://discord.com/api/v9/interactions', data = data, headers = header)

But the program gives me that at the end :

{"code": 50035, "errors": {"data": {"_errors": [{"code": "MODEL_FROM_NON_DICTLIKE", "message": "Models can only be instantiated from something dict-like, got <class 'str'>"}]}}, "message": "Invalid Form Body"}

If you have any ideas to help me I am interested. Thanks.

Upvotes: 2

Views: 3807

Answers (1)

Trimonu
Trimonu

Reputation: 44

try changing data = data to json = data

Upvotes: 1

Related Questions