Adonis Command Logger for Discord

What is this?

Logs Command What Admin Executed. To Check Is The Admin Abusing Their Permission
Save as “Server-CommandLogger” Module Script in Adonis Plugin Folder


return function(Vargs)
	local server, service = Vargs.Server, Vargs.Service
	local logs = {}
	coroutine.wrap(function()
		local discordWebhookUrl = "URL"
		game.HttpService:PostAsync(discordWebhookUrl,game.HttpService:JSONEncode({
			embeds = {
				{
					title = "A New Game Server Loaded",
					description = "`" .. game.JobId or "JobId is Unknown. Maybe on Studio" .. "`",
					color= 3720960
				}
			}
		}))
		while wait(10) do
			if logs == {} then continue end
			 
			local fields = {
				
			}
			for i,v in pairs(logs) do
				local fieldContent = {
					name = v.Player.Name .. " ( " .. v.Player.UserId .. " )",
					value = "`" .. string.sub(v.Desc,1,512) .. "`"
				}
				table.insert(fields,fieldContent)
			 
			end
			if #fields ~= 0  then
				game.HttpService:PostAsync(discordWebhookUrl,game.HttpService:JSONEncode({
					embeds = {
						{
							title = string.format("Commands Server ID:" .. "`" .. game.JobId .."`"),
							color = 38135,
							fields = fields
						}
					}
				}))
			end
			logs = {}
			
		end
	end)()
	coroutine.wrap(function()
		local lastCount = 0
		print(server.Logs)
		while wait()do
			local clogs = server.Logs.Commands
			 
			if clogs.count == lastCount then continue end
			 
			if clogs.snode then
				
				if clogs.snode.data then
					table.insert(logs,clogs.snode.data)
					lastCount = clogs.count
				end
			end
			 
			
		end
 	end)()
	 
end
4 Likes

How to get banned from discord 101

2 Likes

This condition will never be true. Instead, use this:

if #logs == 0 then continue end

Remember that references to tables are memory addresses. Checking if two different tables are equal compares their memory addresses that are not the same. So checking if any table is equal to {} is always false. Yes, even {} == {} is false. They don’t have the same memory address! And a memory address is just a location where the actual data is stored in your RAM.

Well, you kind of did that here. I would use this, though:

if #fields > 0 then

I guess this one is preference! It just reads easier when using >.

1 Like

Discord won’t ban you for this

If you’re continuously spamming the API and they check it for logging, you can be banned for breaching ToS. There’s a reason Roblox’s IP range was banned for a time for this specific reason.

2 Likes

I think it’d be a bit much if they banned you because something was spamming your webhook because if that was the case then instead of people nuking servers they’d just get you banned

You are responsible for the webhook usage, there’s a reason why there is a permission level needed to create one. Do your own research on it before chiming in your opinion.

2 Likes