Advertisement
rrixh

songpixker

Oct 5th, 2023 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. repeat task.wait() until game:IsLoaded()
  2.  
  3. if not getgenv().executedHi then
  4.     getgenv().executedHi = true
  5. else
  6.     return
  7. end
  8. local httprequest = (syn and syn.request) or http and http.request or http_request or (fluxus and fluxus.request) or request
  9.  
  10. local songName,plr
  11. local debounce = false
  12.  
  13. getgenv().stopped = false
  14.  
  15. local function sendMessage(text)
  16.     game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(text, "All")
  17. end
  18.  
  19.  
  20. game:GetService('ReplicatedStorage').DefaultChatSystemChatEvents:WaitForChild('OnMessageDoneFiltering').OnClientEvent:Connect(function(msgdata)
  21.     if plr ~= nil and (msgdata.FromSpeaker == plr or msgdata.FromSpeaker == game:GetService('Players').LocalPlayer.Name) then
  22.         if string.lower(msgdata.Message) == '>stop' then
  23.             getgenv().stopped = true
  24.             debounce = true
  25.             task.wait(3)
  26.             debounce = false
  27.         end
  28.     end
  29.     if debounce or not string.match(msgdata.Message, '>lyrics ') or string.gsub(msgdata.Message, '>lyrics', '') == '' or game:GetService('Players')[msgdata.FromSpeaker] == game:GetService('Players').LocalPlayer then
  30.         return
  31.     end
  32.     debounce = true
  33.     local speaker = msgdata.FromSpeaker
  34.     local msg = string.lower(msgdata.Message):gsub('>lyrics ', ''):gsub('"', ''):gsub(' by ','/')
  35.     local speakerDisplay = game:GetService('Players')[speaker].DisplayName
  36.     plr = game:GetService('Players')[speaker].Name
  37.     songName = string.gsub(msg, " ", ""):lower()
  38.     local response
  39.     local suc,er = pcall(function()
  40.     response = httprequest({
  41.         Url = "https://lyrist.vercel.app/api/" .. songName,
  42.         Method = "GET",
  43.     })
  44.     end)
  45.     if not suc then
  46.     sendMessage('Unexpekted error, please retry')
  47.     task.wait(3)
  48.     debounce = false
  49.     return
  50.     end
  51.     local lyricsData = game:GetService('HttpService'):JSONDecode(response.Body)
  52.     local lyricsTable = {}
  53.     if lyricsData.error and lyricsData.error == "Lyrics Not found" then
  54.         debounce = true
  55.         sendMessage('Lyriks were not found')
  56.         task.wait(3)
  57.         debounce = false
  58.         return
  59.     end
  60.     for line in string.gmatch(lyricsData.lyrics, "[^\n]+") do
  61.         table.insert(lyricsTable, line)
  62.     end
  63.     sendMessage('Fetched lyrics')
  64.     task.wait(2)
  65.     sendMessage('Playing song requested by ' .. speakerDisplay .. '. They kan stop it by saying ">stop"')
  66.     task.wait(3)
  67.     for i, line in ipairs(lyricsTable) do
  68.         if getgenv().stopped then
  69.             getgenv().stopped = false
  70.             break
  71.         end
  72.         sendMessage('🎙️ | ' .. line)
  73.         task.wait(4.7)
  74.     end
  75.     task.wait(3)
  76.     debounce = false
  77.     sendMessage('Ended. You kan request songs again.')
  78. end)
  79.  
  80. task.spawn(function()
  81.     while task.wait(60) do
  82.         if not debounce then
  83.             sendMessage('I am a lyrics bot! Type ">lyrics SongName" and I will sing the song for you!')
  84.             task.wait(2)
  85.             if not debounce then
  86.                 sendMessage('You kan also do ">lyrics SongName by Author"')
  87.             end
  88.         end
  89.     end
  90. end)
  91.  
  92. sendMessage('I am a lyriks bot! Type ">lyrics SongName" and I will sing the song for you!')
  93. task.wait(2)
  94. sendMessage('You kan also do ">lyrics SongName by Author"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement