Advertisement
_DudeWhat_

MC To DIscord

Jan 10th, 2022 (edited)
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local chat = peripheral.find("chatBox")
  2. if not chat then error("No chatbox attached!") end
  3. local dc = require("discord")
  4. if not dc then error("Discord API not installed! Run \"update discord\" to install.") end
  5. local dcData = require("discorddata")
  6. if not dcData then error("Discord Data not configured!") end
  7.  
  8. local function getMinecraftAvatar(uuid)
  9.     return "https://crafatar.com/renders/head/"..uuid
  10. end
  11.  
  12. local function relayMessageToDiscord()
  13.     local event, username, message, uuid, isHidden = os.pullEvent("chat")
  14.     print(username.. " just wrote: ".. message)
  15.     avatar_url = getMinecraftAvatar(uuid)
  16.     dc.webhookMessage(dcData.webhookId, dcData.webhookToken, message, username, avatar_url)
  17. end
  18.  
  19. while true do relayMessageToDiscord() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement