Discord Logging Issue: Getting HTTP 400(Bad request)?

For some reason I keep getting the error HTTP 400(Bad Request).
Problem: Getting the error HTTP 400(Bad Request)
Who made the code? @crywink made the code, I edited it. It’s open source.
Code:

service = nil -- words cant explain how much i hate doing this
--[[
	Adonis Webhook Command Logs
	Author: crywink / Samuel#0440
--]]

-- Services
local HttpService = game:GetService("HttpService")

-- Variables
local Settings = {
	Webhook = "XXXXXX"; -- Replace with your webhook link. (MAKE SURE YOU KEEP THE QUOTES)
	RunForGuests = false; -- Set to true if you want guests (players without admin) commands to be logged.
	Ignore = {}; -- Commands you want ignored. Example: {":fly", ":speed"}
}

local function GetLevel(plr)
	local level = _G.Adonis.GetLevel(plr)

	if level > 0 then
		if level == 1 then
			return "Moderator"
		elseif level == 2 then
			return "Admin"
		elseif level == 3 then
			return "Owner"
		elseif level == 4 then
			return "Creator"
		elseif level == 5 then
			return "Place Owner"
		end
	end
end

local function FindInArray(arr, obj)
	for i = 1, #arr do
		if arr[i] == obj then
			return i
		end
	end
	return nil
end

-- Module
return function()
	service.Events.CommandRan:Connect(function(plr, data)
		local msg = data.Message;
		local cmd = data.Matched;
		local args = data.Args;

		if FindInArray(Settings.Ignore, cmd:lower()) then
			return
		end

		local Level = GetLevel(plr)
		if Level or (not Level and Settings.RunForGuests) then
			HttpService:PostAsync(Settings.Webhook, HttpService:JSONEncode({
				embeds = {{
					title = "Game Admin Logs";
					description = "Command ran";
					color = 8376188;
					fields = {
						{
							name = "Player Name:";
							value = plr.Name;
							inline = true
						},
						{
							name = "Admin Type:";
							value = Level;
							inline = true
						},
						{
							name = "Command Ran:";
							value = msg;
							inline = true
						},
						{
							name = "Command Args:";
							value = args;
							inline = true
						}
					}
				}}
			}))
		end
	end)
end

Code Source: Adonis Admin | Discord Logs

1 Like

Maybe you’re getting error 400 because args value is a array and Discord doesn’t accept arrays as a field value. You can use table.concat to join array elements into a single string

3 Likes

yes. @crywink dm’d me this solution aswell. Thank you! cannot believe i didnt realize this