Lukkit
Search…
Discord Webhooks (http)
This cool little plugin sends a POST request to a Discord webhook and allow users to send a message to a channel. Some things that could be added or changed would be to send all chat messages to discord, prevent users from using @everyone or mentioning users, and running it async so it doesn't slow down the server.

Code

main.lua
1
-- Imports
2
unirest = import("com.mashape.unirest.http.Unirest")
3
color = newInstance("#.wrappers.ChatColorWrapper", {plugin.getPlugin()})
4
5
webhookUrl = "https://discordapp.com/api/webhooks/532360268223741952/1XLKZg9o3a93AMui2BauKUY7SPTWYe2ec_D9gf2UFEvuJ09L8OHJcSXf4j6HoD7j1Cq5"
6
7
local discordCommand = plugin.addCommand({name="discord", permission="lukkit.command.discord"}, function(cmd)
8
-- Convert arguments into a single string
9
argString = ''
10
for i, arg in ipairs(cmd:getArgs()) do
11
argString = argString .. arg
12
end
13
14
-- Make POST request
15
response = unirest:post(webhookUrl):field("username", cmd:getSender():getName()):field("content", argString):asString()
16
17
-- Tell user
18
cmd.getSender():sendMessage(color.GREEN .. 'Message sent!')
19
end)
20
Copied!
Last modified 2yr ago
Copy link
Contents
Code