How do I check if a player is currently banning using Roblox's Ban API?

ive been making a moderation system for my game and i created a system that gives the moderator a players full ban history. everything works except for the fact that i cant seem to get a boolean for whether or not the player is currently banned.

i looked on the devforum for a while but i couldnt find anything useful so im making this post

local isbannedtext = "(player is currently not banned)"
local plrisbanned = false
--(theres a variable called "history" for GetBanHistoryAsync)
if plrisbanned then
	isbannedtext = "(player is currently banned)"
end

any help would be appreciated

Ban history shows whether or not the action was a ban or an unban. The latest ban status in the history will determine whether or not the user is currently banned

this doesnt work if the ban just expires

I haven’t used the ban API yet but cant you get their ban history, check the most recent ban, and compare the ban time to now?

Then why don’t you check the expiry date :exploding_head:

1 Like

i think i can but it uses a weird format so i dont know how

I searched up the format and it’s not too hard to understand.
Source: ISO - ISO 8601 — Date and time format

You will most likely have to add the seconds onto the date and time to figure out the unban date and time. After you get the unban date and time you can check the current date and time to see if it’s greater which means they’re unbanned

i think i got it to work thanks!!!

Use DateTime.fromIsoDate. Next, get the current date with DateTime.now. Access both of their UnixTimestampMillis properties for a difference calculation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.