Move the report commands into exp_reports

The create-report, get-reports and clear-reports commands now live in the
plugin's own module next to the functions they call, with their locale.
The permissions keep their exp_scenario.command names because the command
authority derives them from the command name.

The Discord report alert in exp_scenario is gone since exp_reports posts to
its own webhook. The shared add_player stub takes an options table with
connected and admin defaulting to true and false, replacing the copy in
the exp_reports test environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-09-26 23:22:18 +00:00
1 parent e47f41d440
commit 9ddb7b362b
20 files changed
+95 -155

No files matched your search

-62
View File
@@ -1,62 +0,0 @@
--[[-- Commands - Reports
Adds a commands that allow players to report other players
]]
local Commands = require("modules/exp_commands")
local parse_input = Commands.parse_input
local Roles = require("modules/exp_roles")
local player_has_permission = Roles.player_has_permission
local Reports = require("modules/exp_reports")
--- @param input string
--- @param player LuaPlayer
--- @return Commands.Status
--- @return LuaPlayer | LocalisedString
local function reportable_player(input, player)
local success, status, result = parse_input(input, player, Commands.types.player)
if not success then return status, result end
--- @cast result LuaPlayer
if player_has_permission(input, "exp_scenario.bypass.reports") then
return Commands.status.invalid_input{ "exp-commands_reports.player-immune" }
elseif player == input then
return Commands.status.invalid_input{ "exp-commands_reports.self-report" }
else
return Commands.status.success(result)
end
end
--- Reports a player and notifies admins, the outcome is printed once the controller answers
Commands.new("create-report", { "exp-commands_reports.description-create" })
:argument("player", { "exp-commands_reports.arg-player-create" }, reportable_player)
:argument("reason", { "exp-commands_reports.arg-reason" }, Commands.types.string)
:enable_auto_concatenation()
:add_aliases{ "report" }
:register(function(player, other_player, reason)
--- @cast other_player LuaPlayer
--- @cast reason string
Reports.create_report(player, other_player, reason)
end)
--- Lists the reports against a player, or the number against every player, printed once the controller answers
Commands.new("get-reports", { "exp-commands_reports.description-get" })
:optional("player", { "exp-commands_reports.arg-player-get" }, Commands.types.player)
:add_aliases{ "reports" }
:add_flags{ "admin_only" }
:register(function(player, other_player)
--- @cast other_player LuaPlayer?
Reports.list_reports(player, other_player)
end)
--- Clears all reports from a player or just the report from one player, printed once the controller answers
Commands.new("clear-reports", { "exp-commands_reports.description-clear" })
:argument("player", { "exp-commands_reports.arg-player-clear" }, Commands.types.player)
:optional("from-player", { "exp-commands_reports.arg-from-player" }, Commands.types.player)
:add_flags{ "admin_only" }
:register(function(player, other_player, from_player)
--- @cast other_player LuaPlayer
--- @cast from_player LuaPlayer?
Reports.delete_reports(player, other_player, from_player and from_player.name)
end)
-1
View File
@@ -30,7 +30,6 @@ require("modules/exp_scenario/commands/me")
require("modules/exp_scenario/commands/rainbow")
require("modules/exp_scenario/commands/ratio")
require("modules/exp_scenario/commands/repair")
require("modules/exp_scenario/commands/reports")
require("modules/exp_scenario/commands/roles")
require("modules/exp_scenario/commands/search")
require("modules/exp_scenario/commands/spectate")
@@ -97,40 +97,6 @@ if config.entity_protection then
end
end
--- Reports added and removed
if config.player_reports then
local Reports = require("modules/exp_reports")
--- @param event EventData.ExpReports.on_player_reported
events[Reports.on_player_reported] = function(event)
local player_name, by_player_name = get_player_name(event)
emit_event{
title = "Report",
description = "A player was reported",
color = Colors.yellow,
fields = {
{ name = "Player", inline = true, value = append_playtime(player_name) },
{ name = "By", inline = true, value = append_playtime(by_player_name) },
{ name = "Report Count", inline = true, value = tostring(event.report_count) },
{ name = "Reason", value = event.reason },
},
}
end
--- @param event EventData.ExpReports.on_reports_deleted
events[Reports.on_reports_deleted] = function(event)
local player_name, by_player_name = get_player_name(event)
emit_event{
title = "Reports Removed",
description = "A player has reports removed",
color = Colors.green,
fields = {
{ name = "Player", inline = true, value = append_playtime(player_name) },
{ name = "By", inline = true, value = append_playtime(by_player_name) },
{ name = "Report Count", inline = true, value = tostring(event.count) },
},
}
end
end
--- When a player is jailed or unjailed
if config.player_jail then
local Jail = require("modules/exp_scenario/control/jail")
-12
View File
@@ -161,18 +161,6 @@ description=Repairs entities on your force around you.
response-revive=__1__ entities were revived.
response-heal=__1__ entities were healed.
[exp-commands_reports]
description-create=Reports a player and notifies moderators
description-get=Gets a list of all reports that a player has on them. If no player then lists all players and the number of reports on them.
description-clear=Clears all reports from a player or just the report from one player.
arg-player-create=Player you want to report.
arg-player-get=Player to get the reports of.
arg-player-clear=Player to clear the reports of.
arg-reason=Reason you want to report this player.
arg-from-player=Only remove the report from this player.
player-immune=This player can not be reported.
self-report=You cannot report yourself.
[exp-commands_roles]
description-assign=Assigns a role to a player.
description-unassign=Unassigns a role from a player.
-22
View File
@@ -165,28 +165,6 @@ arg-range=半徑
response-revive=__1__ 個建築恢復。
response-heal=回滿 __2__ 個建築耐久。
[exp-commands_reports]
description-create=檢舉用戶並通知管理員。
description-get=取得用戶的報告清單。如果沒有設定用戶,則列出所有用戶以及有關他們的報告數量。
description-clear=清除一名用戶的所有報告或僅清除一名用戶的報告。
arg-player-create=用戶
arg-player-get=用戶
arg-player-clear=用戶
arg-reason=原因
arg-from-player=用戶
player-immune=用戶不能被舉報
self-report=你不能舉報自己。
response=__1__ 因 __2__ 被舉報了。
response-admin=__1__ 因 __3__ 被 __2__ 舉報了。
already-reported=你已經舉報過該用戶了,你可以讓管理員清除報告來重寫。
not-reported=該用戶沒有被舉報的紀錄。
not-reported-by=該用戶沒有被 __1__ 舉報的紀錄。
reports-title==該用戶現在的被舉報紀錄:
player-title=__1__ 有 __2__ 項被舉報的紀錄:
list-element=__1__: __2__
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
[exp-commands_roles]
description-assign=為用戶指配用戶組。
description-unassign=為用戶取消指配用戶組。
-22
View File
@@ -165,28 +165,6 @@ arg-range=半徑
response-revive=__1__ 個建築恢復。
response-heal=回滿 __2__ 個建築耐久。
[exp-commands_reports]
description-create=檢舉用戶並通知管理員。
description-get=取得用戶的報告清單。如果沒有設定用戶,則列出所有用戶以及有關他們的報告數量。
description-clear=清除一名用戶的所有報告或僅清除一名用戶的報告。
arg-player-create=用戶
arg-player-get=用戶
arg-player-clear=用戶
arg-reason=原因
arg-from-player=用戶
player-immune=用戶不能被舉報
self-report=你不能舉報自己。
response=__1__ 因 __2__ 被舉報了。
response-admin=__1__ 因 __3__ 被 __2__ 舉報了。
already-reported=你已經舉報過該用戶了,你可以讓管理員清除報告來重寫。
not-reported=該用戶沒有被舉報的紀錄。
not-reported-by=該用戶沒有被 __1__ 舉報的紀錄。
reports-title==該用戶現在的被舉報紀錄:
player-title=__1__ 有 __2__ 項被舉報的紀錄:
list-element=__1__: __2__
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
[exp-commands_roles]
description-assign=為用戶指配用戶組。
description-unassign=為用戶取消指配用戶組。