Forked from ianklatzco/discord-bot-post-message.py
Last active
March 17, 2022 16:49
-
-
Save preindex/2d594459f094ebda51f75b176145e7e6 to your computer and use it in GitHub Desktop.
sends messages to a discord channel using a bot via http POST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Post a message to discord api via a bot | |
-- Originally created by ianklatzco, forked and ported to lua by xxxYoloxxx999#2166 (preindex) | |
-- You don't need a library to do this, you just need something that runs lua to execute and a request function. | |
local channelId = 'your_id_goes_here' | |
local botToken = 'your_token_here' | |
local ToPost = { -- Stuff you need to post | |
['content'] = 'hello world!' | |
} | |
local baseURL = string.format('https://discordapp.com/api/channels/%s/messages', channelID) | |
local headers = { | |
['Authorization'] = string.format('Bot %s', botToken), | |
['Content-Type'] = 'application/json', | |
['User-Agent'] = 'xxxYoloxxx999#2166 (https://system-exodus.com, v0.1)' | |
} | |
-- Request using coro.request | |
local request = coro.request('POST', baseURL, headers, ToPost) | |
-- Request using any request function | |
local Request = request({ | |
Url = baseURL, | |
Method = 'POST', | |
Headers = headers, | |
Body = ToPost | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment