Send Message to Discord Using API Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Send Message to Discord Using API

08 Sep 2017, 11:02

Probably been asked, and I don't want to fish out the commands and functions from Geek's Discord.ahk.
What is the "mini-script" that sends a message to a specified channel of Discord?

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Send Message to Discord Using API  Topic is solved

08 Sep 2017, 11:04

Nevermind I had the code in a file.
I'm stupid.

Code: Select all

Text := StrReplace(StrReplace(Text, "\", "\\"), """", "\""")
Http := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
Http.Open("POST", "https://discordapp.com/api/channels/" ChanID "/messages")
Out := Http.Open("GET", "https://discordapp.com/api/channels/" ChanID)
Http.SetRequestHeader("Authorization", Token)
Http.SetRequestHeader("Content-Type", "application/json")
Http.Send("{""content"": """ Text """}")

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

dragonre
Posts: 1
Joined: 21 Jun 2018, 18:36

Re: Send Message to Discord Using API

21 Jun 2018, 18:37

I've set up a discord bot, joined it to my server. In your code I replaced ChanID with my channel ID, the Token with my bot's token, and put in my own text. When I try to send a test message I don't get an error, but no message is sent. Is there something else I'm missing?
dzint
Posts: 2
Joined: 02 Dec 2019, 20:03

Re: Send Message to Discord Using API

02 Dec 2019, 20:34

Ive been trying to figure this out but I cant get it to work, can you send some example code that works to send a message to discord webhook?
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Re: Send Message to Discord Using API

21 Mar 2022, 18:59

Delta, I've tried setting it up too but it won't send really, and g33kdude says that Discord.ahk is probably outdated since the api has changed, so it might be that, do you have perhaps an updated version? or an updated version of discord.ahk?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput and 330 guests