[Python] How to send message in discord channel by its API

Discussão em 'Python' iniciado por Stack, Abril 17, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to send a message in my channel. As I have read, I need to pass the message as the content parameter in the post request. Here is the short Python code for that:

    import requests

    URL = "https://discordapp.com/api/webhooks/super/secret

    r = requests.get(URL,data={"content":"123"},headers={"Content-Type":"application/json"})

    print(r.text)


    But it gives me a response:

    <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
    <p><b>400.</b> <ins>That’s an error.</ins>
    <p>Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins>

    Continue reading...

Compartilhe esta Página