Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Adonis Command Logs to Discord [WEBHOOK]?

I'm trying to get it to where any Adonis admin command that is executed will show up in my discord channel. I'm not a scripter, and I need major help.-- I do not want non-admins showing up in the channel whenever they chat ":". I just want the administrator's admin commands. I also have a format that I want in the response or "log". If anyone can help, it would be much appreciated!

local HTTP = game:GetService("HttpService")
local Key = ""

game.service.Events.CommandRan:connect(function(p,msg,command,args,index,table,ran,error)
        if ran then 
            local arg = ""
            if args then
                for i,v in pairs(args) do
                    arg = arg..""..v
                end
            end
            
            local data = {Key,tostring(p)..": "..msg,
                "\nPlayer: "..tostring(p)..
                "--------------------------------------------"..
                "\nMessage: "..tostring(msg)..
                "\n"..
                "\nCommand: "..tostring(command)..
                "\nArguments: "..tostring(arg)..
                "\n"..
                "\nTime: "..tostring(service.GetTime())..
                "\nSuccessful: "..tostring(ran)..
                "\nError: "..tostring(error)..
                "\n--------------------------------------------")
            HTTP:PostAsync(Key,HTTP:JSONEncode(HookData))
        end
    end)
end)

3 comments

0

Adonis has a plugin API, use that

0

i still ned help @machopiggies

0

My other post got taken down for "Off-Topic" and it was because of a lua table that is later converted to json.

1 answer

Try this:

local data = {
	['content'] = 
		"<The Message>"..argument.."<Other stuff>"
}
data = HTTP:JSONEncode(data)
HTTP:PostAsync(Key, data)

When you send a message to Discord, you're sending JSON data. What it requires when you send it is a "content" part. That's the message that it sends. You have to say ['content'] = "Message" and then JSONEncode() that, then you're able to send it using PostAsync(Key, EncodedJSON)

Adding onto the 2nd part, I'm not sure if that will run when a non-admin does ":", but if it does, Adonis comes with an API, and it's all shown in a script (Commented Out).

There's a _G.Adonis.CheckAdmin(Player), but I've never been able to get that to work. If you get that function to work (TELL ME PLEASE), you can see the return value of it. If it's a boolean:

local IsAdmin = _G.Adonis.CheckAdmin(Player) --Or whatever you do to make it work
if IsAdmin then --or if IsAdmin == true then
	--Player Is an Admin
else
	--Player Isn't an Admin
end

This discussion is preserved as it was. New answers, comments, and votes are closed.