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

How can I make Adonis Admin Logs via Discord Webook?

Asked by 4 years ago
Edited 4 years ago

I've tried basically everything, but nothing I find seems to work! If somebody knows how to do this, please tell me, it would really help me. The code I've tried but doesn't seem to work usually is something along the lines of this

local WebhookId     = ""
local WebhookToken  = ""

server = nil 
service = nil

local Http = game:GetService("HttpService")
local webHook = require(script.WebhookAPI)
local Discord_Webhook = webHook.new(WebhookId,WebhookToken) 
local PlaceName = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name


return function() 

    function LvlFromNum(p)
        local level = server.Admin.GetLevel(p)
        if level >= 4 then
            return 'Creator'
        elseif level >= 3 then 
            return 'Owner'
        elseif level >= 2 then
            return 'Admin'
        elseif level >= 1 then
            return 'Mod'
        else
            return 'Player'
        end 
    end

    service.Events.CommandRan:connect(function(p,msg,command,args,index,table,ran,error)

        if ran then 
            local arg = ""
            if args and #args > 1 then
                for i,v in pairs(args) do
                    arg = arg..","..v
                end
            else
                arg = args[1]
            end

            Discord_Webhook:post{
                username = 'Command Logs',
                embeds = {
                    {
                        fields = {
                            {
                                name = 'Player',
                                value = tostring(p.Name)..' | '..LvlFromNum(p)
                            },
                            {
                                name = 'Message',
                                value = tostring(msg)
                            },
                            {
                                name = 'Command',
                                value = tostring(command)
                            },
                            {
                                name = 'Arguments',
                                value = tostring(arg)
                            }                           
                        },

                        color = 16518199,

                        footer = {
                            text = tostring(PlaceName)..' | '..tostring(service.GetTime())
                        }
                    }
                }   
            }
        end
    end)
end


And the Webhook API Script is


local webHook = {} webHook.__index = webHook local Http = game:GetService("HttpService") function webHook.new(id,key) local mt = setmetatable({id=id,key=key}, webHook) return mt end function webHook:post(config,host) local data = nil local success = pcall(function() data = Http:JSONEncode(config) end) if not success then warn("Conversion error, please re-check your data.") return end Http:PostAsync("https://discordapp.com/api/webhooks/"..self.id.."/"..self.key,data) end return webHook

Please help if you can, thank you!

1 answer

Log in to vote
0
Answered by 4 years ago

I don't think you can actually sent it to a server via a webhook unless you set up a special bot connected with Adonis. I know you can log commands via Trello, so go into the Settings script until you find the set-up prompt for Trello services (also includes setup instructions). Hope this helps!

0
Is there a way to have the webhook send a message containing any message that starts with ":", and say which user and when it happened? Explorer2021 22 — 4y
0
Honestly, you most likely can, and the script is most likely in java. Sorry. TotalElevation 45 — 4y
Ad

Answer this question