Тема: AHK: Discord API Отправка сообщений, используя Token
Здравствуйте!
Пытался найти тему на форуме, с моей проблемой.
Суть заключается в чём..
нужно отправлять, с помощью AHK, сообщения в Discord пользователя, посредством `WebRequest`, то есть без наличия Discord приложения.
Хотелось бы хоть какого-нибудь примера для отправки в личку пользователю.
Спасибо!
Нашел вот это: https://github.com/G33kDude/Discord.ahk … iscord.ahk, но я без понятия как с ним работать .
UPD:
Нашел решение попроще.
1. Создаем Discord чат канал.
2. Зайти в "Настроить канал".
3. Интеграция -> Вебхуки -> Новый вебхук
4. Даём имя и выбираем канал где будет наш бот.
5. копируем URL полученного вебхука.
Интегрируем данный вебхук в этот код:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Credit: https://www.reddit.com/r/AutoHotkey/comments/gybnyu/discord_webhook_post_fancy_edition/
;User Settings -> Notifications -> Push Notification Inactive Timeout: 1 minute
;Turn on Discord Developer Mode: User Settings -> Appearance -> Scroll to bottom and check developer mode
;Make sure to disable streamer mode User Settings -> Streamer Mode -> Disable
;This allows you to copy User/Server IDs when you right Click
;Use that ID in your content message as <@USERID> to do @mentions
;` Example: <@12345678910112> or <#channelID>
;Generate webhook for channel
sendError("cutting trees")
sendError(msg){
url:="СЮДА ВАШУ ССЫЛКУ" ; use the url from Discord webhook bot
postdata=
(
{
"content": "СЮДА ВАШ ТЕКСТ ИЛИ %ПЕРЕМЕННУЮ%."
}
)
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("POST", url, false)
WebRequest.SetRequestHeader("Content-Type", "application/json")
WebRequest.Send(postdata)
}
Источник: https://www.reddit.com/r/AutoHotkey/com … y_edition/