mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-11 23:54:52 +09:00
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>
63 lines
2.7 KiB
Lua
63 lines
2.7 KiB
Lua
--[[-- ExpReports - Commands
|
|
Commands which let players report each other and admins manage the reports
|
|
]]
|
|
|
|
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(result, "exp_scenario.bypass.reports") then
|
|
return Commands.status.invalid_input{ "exp-reports_commands.player-immune" }
|
|
elseif player == result then
|
|
return Commands.status.invalid_input{ "exp-reports_commands.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-reports_commands.description-create" })
|
|
:argument("player", { "exp-reports_commands.arg-player-create" }, reportable_player)
|
|
:argument("reason", { "exp-reports_commands.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-reports_commands.description-get" })
|
|
:optional("player", { "exp-reports_commands.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-reports_commands.description-clear" })
|
|
:argument("player", { "exp-reports_commands.arg-player-clear" }, Commands.types.player)
|
|
:optional("from-player", { "exp-reports_commands.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)
|