Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local WebHookUrl = "https://discordapp.com/api/webhooks/326825729914306560/wroC2nxgN9Qz_7YmMjbGkdpMslLrnOjYqPjC0rUpRI-Cp07uV20nHSrJYNJSeDb78KnQ"
- local RetrieveMessageUrl = "https://canary.discordapp.com/api/v6/channels/326825710675034119/messages"
- local BotAuth = "Bot MzI2ODIxODA2MzgxOTg5ODk4.DCsYCg.TOLnzSYMjcmSKy3Tm4GJ9Ij_8Zg"
- local RetrievedMessageIds = {}
- local Players, Http = game:service'Players', game:service'HttpService'
- spawn(function()
- Chat = game:GetService("ServerScriptService")
- Chat = Chat:WaitForChild("ChatServiceRunner")
- Chat = Chat:WaitForChild("ChatService")
- Chat = require(Chat)
- GetSpeaker = Chat.GetSpeaker;
- AddSpeaker = Chat.AddSpeaker;
- end)
- function PostToDiscord(Content, WebHook)
- local Data = game:GetService("HttpService"):PostAsync(WebHook, game:GetService("HttpService"):JSONEncode(Content)) do
- Data = game:GetService("HttpService"):JSONDecode(Data)
- RetrievedMessageIds[Data.id]= true
- end
- end
- function RetrieveMessages(doCallback, callBack)
- local Rtn = game:GetService("HttpService"):GetAsync(RetrieveMessageUrl, false, {
- authorization = BotAuth
- })
- Rtn = game:GetService("HttpService"):JSONDecode(Rtn)
- for i,Message in next, Rtn do
- if (RetrievedMessageIds[Message.id] == nil) then
- RetrievedMessageIds[Message.id] = true
- if (doCallback) then
- delay(0, function()
- callBack(Message.author.username, Message.content, Message.author.bot == true)
- end)
- end
- end
- end
- end
- RetrieveMessages(false)
- spawn(function()
- while wait(1) do
- RetrieveMessages(true, function(Speaker, Message, isBot)
- if (Chat and AddSpeaker and GetSpeaker) then
- local speakerObj,botPrefix do
- botPrefix = isBot and "Server: "
- pcall(function()
- speakerObj = GetSpeaker(Chat, botPrefix .. Speaker)
- end)
- if (not speakerObj) then
- AddSpeaker(Chat, botPrefix .. Speaker)
- speakerObj = GetSpeaker(Chat, botPrefix .. Speaker)
- speakerObj:JoinChannel("All")
- end
- speakerObj:SayMessage(Message, "All")
- end
- else
- warn("Chat not found!", Chat == nil and "No chat" or "", AddSpeaker == nil and "No AddSpeaker" or "", GetSpeaker == nil and "No GetSpeaker" or "" )
- end
- if (isBot) then return 0; end;
- end)
- end
- end)
- for i,v in next, game:GetService("Players"):GetPlayers() do
- v.Chatted:connect(function(Msg)
- PostToDiscord({
- username = "HighMessageHandler";
- content = "**" .. v.Name .. ":** " .. Msg;
- }, WebHookUrl)
- end)
- end
- game:GetService("Players").PlayerAdded:connect(function(v)
- v.Chatted:connect(function(Msg)
- PostToDiscord({
- username = "HighMessageHandler";
- content = "**" .. v.Name .. ":** " .. Msg;
- }, WebHookUrl)
- end)
- end)
- return nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement