Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

code works with one function but not another (DISCORDIA)?

Asked by
Imperialy 149
5 years ago
Edited 5 years ago

so I have my minify function, but when I try to minify the same thing but one is from an http request from pastebin, it outputs differently

01local function minify(msg)
02    local scr = {
03        msg
04 
05    }
06 
07    local result = ""
08    local result = ""
09 
10    function getLines(src)
11        local result = {}
12        local start = 1
13        for i = 1,#src do
14            if string.sub(src, i, i) == "\n" then
15                table.insert(result, #result + 1, src:sub(start, i - 1))
View all 59 lines...

lets say the code I want to minify is this

1for i = 1,50 do
2    print(i)
3end

when I minify the actual message from discord, it outputs for i = 1,50 do print(i) end; but, If that code was in a pastebin, it outputs

1for i = 1,50 do
2 ; print(i)
3 ; end;

here is the way I formatted it

01if content:lower():sub(1,8) == prefix.."minify " then
02    if content:lower():find("https://pastebin.com") then
03        coroutine.wrap(function()
04            local link = content:sub(9)
05            if link:find("raw") then message:reply("remove the raw from the script") return end
06            link = link:gsub("https://pastebin.com","https://pastebin.com/raw")
07            local result, body = http.request("GET", link)
08            message:reply(minify(body)) -- returns that weird version of the code
09            print(body) -- prints the same exact code
10            local channel = message.channel
11            channel:send{
12                file = {'script.txt',minify(body)}
13            }
14        end)()
15    else
View all 25 lines...

Answer this question