<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Discord API Отправка сообщений, используя Token]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17269&amp;type=atom" />
	<updated>2022-07-25T17:35:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17269</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Discord API Отправка сообщений, используя Token]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=154050#p154050" />
			<content type="html"><![CDATA[<p><strong>Clannad5</strong>, апишка, которая находится по ссылке, работает с сервером. Не вижу там ни одной функции, которая помогла бы решить вашу задачу. Самое близкое - SendMessage(), но она работает с каналами. Если у вас задача отправлять что-то одному пользователю, то можно добавить его на сервер и выделить ему его личный канал, тогда можно попробовать что-то такое:<br /></p><div class="codebox"><pre><code>
#include Discord.ahk ; Подключаем апи дискорда, нужно указать путь, если не в папке скрипта

Discord._New(*сюда токен бота дискорда*) ; Инициализация бота

Discord.SendMessage(*айди канала*, &quot;Текст&quot;) ; Отправка текста

</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Madmer]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42664</uri>
			</author>
			<updated>2022-07-25T17:35:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=154050#p154050</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Discord API Отправка сообщений, используя Token]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=154049#p154049" />
			<content type="html"><![CDATA[<p>Здравствуйте!</p><p>Пытался найти тему на форуме, с моей проблемой.<br />Суть заключается в чём..</p><p>нужно отправлять, с помощью AHK, сообщения в Discord пользователя, посредством `WebRequest`, то есть без наличия Discord приложения.<br />Хотелось бы хоть какого-нибудь примера для отправки в личку пользователю.<br />Спасибо!</p><p>Нашел вот это: <a href="https://github.com/G33kDude/Discord.ahk/blob/master/Discord.ahk">https://github.com/G33kDude/Discord.ahk … iscord.ahk</a>, но я без понятия как с ним работать <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />.</p><p>UPD:<br />Нашел решение попроще.<br />1. Создаем Discord чат канал.<br />2. Зайти в &quot;Настроить канал&quot;.<br />3. Интеграция -&gt; Вебхуки -&gt; Новый вебхук<br />4. Даём имя и выбираем канал где будет наш бот.<br />5. копируем URL полученного вебхука.</p><p>Интегрируем данный вебхук в этот код:</p><div class="codebox"><pre><code>
#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 -&gt; Notifications -&gt; Push Notification Inactive Timeout: 1 minute
;Turn on Discord Developer Mode: User Settings -&gt; Appearance -&gt; Scroll to bottom and check developer mode
;Make sure to disable streamer mode User Settings -&gt; Streamer Mode -&gt; Disable
		;This allows you to copy User/Server IDs when you right Click
		;Use that ID in your content message as &lt;@USERID&gt; to do @mentions
		;` Example: &lt;@12345678910112&gt; or &lt;#channelID&gt;
	  ;Generate webhook for channel

sendError(&quot;cutting trees&quot;)

sendError(msg){
	url:=&quot;СЮДА ВАШУ ССЫЛКУ&quot; ; use the url from Discord webhook bot
	postdata=
	(
	{
	  &quot;content&quot;: &quot;СЮДА ВАШ ТЕКСТ ИЛИ %ПЕРЕМЕННУЮ%.&quot;
	}
	)
	
	WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
	WebRequest.Open(&quot;POST&quot;, url, false)
	WebRequest.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
	WebRequest.Send(postdata)  
}
</code></pre></div><p>Источник: <a href="https://www.reddit.com/r/AutoHotkey/comments/gybnyu/discord_webhook_post_fancy_edition/">https://www.reddit.com/r/AutoHotkey/com … y_edition/</a></p>]]></content>
			<author>
				<name><![CDATA[Clannad5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39853</uri>
			</author>
			<updated>2022-07-25T16:23:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=154049#p154049</id>
		</entry>
</feed>
