-
-
Save foopis23/d03661491981947c4f161554db7ec7cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
local lastSentMessage = os.epoch() -- last time a message was sent in ms | |
function sendDiscordMessage(message) | |
local url = '' | |
local headers = { | |
['Content-Type'] = 'application/json', | |
} | |
local data = { | |
content = message | |
} | |
local jsonData = textutils.serializeJSON(data) | |
local response = http.post(url, jsonData, headers) | |
if response then | |
local responseBody = response.readAll() | |
response.close() | |
return responseBody | |
else | |
print('Failed to send message') | |
end | |
end | |
while true do | |
if redstone.getInput('right') then | |
print('Lava Working') | |
local currentTime = os.epoch() | |
if currentTime - lastSentMessage >= 30000 then -- 30 seconds in ms | |
sendDiscordMessage('Lava Working') | |
lastSentMessage = currentTime | |
end | |
end | |
sleep(0.1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment