The code:
Non-binding license
– [[ made by janis <@the_h0lysandwich> ]] –
–[[
hey there, thanks for using my ban module using the new BanAPI from Roblox.
PLEASE READ THE FOLLOWING NOTES, THEY ARE MOSTLY RULES. I’M NOT LIABLE FOR ANYTHING YOU DO WITH THIS MODULE.
NOTE: According to the new BanAPI’s TOS, you have to list the rules of YOUR experience somewhere accessible for the Players.
NOTE 2: The Reason/etc has to follow Roblox’s TOS, I’m not liable for anything you do with this Module.
BanAPI Forum Note: You can determine the reason and duration of the ban, as long as it follows Roblox Community Standards and Terms of Use.
BanAPI Forum Note 2: You will now be allowed to establish your own Experience Rules, and moderate your own experiences according to those rules,
as long as those rules abide by the Roblox TOS and Community Standarts, as well as the Ban API Guidance that applies to the use of Ban API.
Roblox may take action against creators who violate the Roblox Terms of Use in their application of the Ban API.
Instruction is in the Script called “Instruction” inside the Module.
BanAPI Forum: Introducing the Ban API and Alt Account Detection
also, DO NOT REPUBLISH, IF YOU DO OTHERWISE, WE WILL FILE A PROPERTY CLAIM.
]]
local run = game:GetService("RunService")
local plrs = game:GetService("Players")
local defaults = {
Duration = 0,
DisplayReason = "An Moderator has banned you.",
PrivateReason = "Moderator Note",
ApplyToUniverse = true,
ExcludeAltAccounts = false,
}
local ban = {}
ban.BanSinglePlayer = function(player:Player, duration:string, reason:string, privateReason:string, applyToUniverse:boolean, excludeAltAccounts:boolean)
if run:IsClient() then return end
if player.Parent == not plrs then return end
local data:BanConfigType = {
UserIds = {player.UserId},
ApplyToUniverse = applyToUniverse or defaults.ApplyToUniverse,
Duration = duration or defaults.Duration,
DisplayReason = reason or defaults.DisplayReason,
PrivateReason = privateReason or defaults.PrivateReason,
ExcludeAltAccounts = excludeAltAccounts or defaults.ExcludeAltAccounts,
}
local success, result = pcall(function()
plrs:BanAsync(data)
end)
return success, result
end
ban.BanUserId = function(userId_s:number, duration:string, reason:string, privateReason:string, applyToUniverse:boolean, excludeAltAccounts:boolean)
if run:IsClient() then return end
local data:BanConfigType = {
UserIds = userId_s,
ApplyToUniverse = applyToUniverse or defaults.ApplyToUniverse,
Duration = duration or defaults.Duration,
DisplayReason = reason or defaults.DisplayReason,
PrivateReason = privateReason or defaults.PrivateReason,
ExcludeAltAccounts = excludeAltAccounts or defaults.ExcludeAltAccounts,
}
local success, result = pcall(function()
plrs:BanAsync(data)
end)
return success, result
end
ban.BanMultiplePlayers = function(playerList, duration:string, reason:string, privateReason:string, applyToUniverse:boolean, excludeAltAccounts:boolean)
if run:IsClient() then return end
local array = {}
for _, player in playerList do
if player.Parent == plrs then
table.insert(array, player.UserId)
else
return
end
end
local data:BanConfigType = {
UserIds = array,
ApplyToUniverse = applyToUniverse or defaults.ApplyToUniverse,
Duration = duration or defaults.Duration,
DisplayReason = reason or defaults.DisplayReason,
PrivateReason = privateReason or defaults.PrivateReason,
ExcludeAltAccounts = excludeAltAccounts or defaults.ExcludeAltAccounts,
}
local success, result = pcall(function()
plrs:BanAsync(data)
end)
return success, result
end
ban.Unban = function(userId_s:number, applyToUniverse:boolean)
if run:IsClient() then return end
local data:UnbanConfigType = {
UserIds = {userId_s},
ApplyToUniverse = applyToUniverse or defaults.ApplyToUniverse,
}
local success, result = pcall(function()
plrs:UnbanAsync(data)
end)
return success, result
end
ban.GetBanHistory = function(userId:number)
if run:IsClient() then return end
pcall(function()
return plrs:GetBanHistoryAsync(userId)
end)
end
return ban
This is just a wrapper for the Ban API, and doesn’t add any extra functionality. I wouldn’t consider it easier to use than the Ban API itself!