Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands for Roblox Ban API #327

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Cmdr/BuiltInCommands/Admin/ban.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
return {
Name = "ban";
Description = "Bans a player or set of players.";
Group = "DefaultAdmin";
Args = {
{
Type = "playerIds";
Name = "players";
Description = "The players to ban.";
},
{
Type = "duration";
Name = "duration";
Description = "How long the ban should last. A negative value means a permanent ban.";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a more explicit way to specify permanence; negative durations in general seem quite silly. In my game, we do this through the absence of a duration, but that can be confusing to people new to Cmdr.

  • Maybe separate tempban and permban commands?
  • Maybe through a prefixed union type, e.g. ! means permanent. (In practice, this could be something like duration ! string)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this. I believe we could just keep the existing command and use a prefixed union type. Though, with a type of "duration ! string" and a value of just !, the type validator for primitive strings would flag it, as it's considered a nil value.

Maybe this could be resolved by requiring the user to use !permanent as the value?

},
{
Type = "string";
Name = "reason";
Description = "The reason for the ban. This is shown to the player(s) and saved in history.";
},
};
}
18 changes: 18 additions & 0 deletions Cmdr/BuiltInCommands/Admin/banServer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local Players = game:GetService("Players")

return function (_, players, duration, reason)
if duration <= 0 then
duration = -1
end

Players:BanAsync({
UserIds = players,
Duration = duration,
DisplayReason = reason,
PrivateReason = reason,
ExcludeAltAccounts = false,
ApplyToUniverse = true,
})

return ("Banned %d players."):format(#players)
end
12 changes: 12 additions & 0 deletions Cmdr/BuiltInCommands/Admin/unban.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
return {
Name = "unban";
Description = "Unbans a player or set of players.";
Group = "DefaultAdmin";
Args = {
{
Type = "playerIds";
Name = "players";
Description = "The players to unban.";
},
};
}
10 changes: 10 additions & 0 deletions Cmdr/BuiltInCommands/Admin/unbanServer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local Players = game:GetService("Players")

return function (_, players)
Players:UnbanAsync({
UserIds = players,
ApplyToUniverse = true,
})

return ("Unbanned %d players."):format(#players)
end