Skip to content

Instantly share code, notes, and snippets.

@foopis23
Last active May 1, 2025 21:00
Show Gist options
  • Save foopis23/d03661491981947c4f161554db7ec7cd to your computer and use it in GitHub Desktop.
Save foopis23/d03661491981947c4f161554db7ec7cd to your computer and use it in GitHub Desktop.
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