Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local query = (parameters or ""):gsub("%s+", "%%20")
- if query == "" then
- return discord.sendError("apis", "Invalid query")
- end
- local head, body = discord.http("https://www.programmableweb.com/category/all/apis?keyword=" .. query)
- print(body)
- local fields = {}
- for api in body:gmatch("<tr .->(.-)</tr>") do
- if #fields < 10 then
- local link, name, desc, cat, followers = api:match("<a href=\"(.-)\">(.-)</a>.-<td.->(.-)</td>.-<a href=\"/category/.-\">(.-)</a></td><td.-> (%d+)</td>")
- fields[#fields + 1] = {name=name, value=(desc and desc:gsub("</?strong>", "**") or "") .. "\n👥 " .. followers .. " | 🗂 " .. cat .. " | [link](https://www.programmableweb.com" .. link .. ")"}
- else break end
- end
- discord.reply {
- embed = {
- description = ":mag_right: Searched for `" .. parameters .. "`\n Check all results [here](https://www.programmableweb.com/category/all/apis?keyword=" .. query .. ")",
- title = "Search APIs",
- fields = fields,
- color = 0x5588ff
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement