Added playtime to some alerts

This commit is contained in:
Cooldude2606
2021-05-10 20:22:45 +01:00
parent 2a66e83d1e
commit 83a2b1d631
2 changed files with 11 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
-- @config Discord-Alerts
return {
show_playtime=true,
entity_protection=true,
player_reports=true,
player_warnings=true,

View File

@@ -6,6 +6,13 @@ local Colors = require 'utils.color_presets' --- @dep utils.color_presets
local write_json, format_time = _C.write_json, _C.format_time --- @dep expcore.common
local config = require 'config.discord_alerts' --- @dep config.discord_alerts
local function append_playtime(player_name)
if not config.show_playtime then return player_name end
local player = game.get_player(player_name)
if not player then return player_name end
return player.name..' ('..format_time(player.online_time)..')'
end
local function get_player_name(event)
local player = game.players[event.player_index]
return player.name, event.by_player_name
@@ -85,7 +92,7 @@ if config.entity_protection then
title='Entity Protection',
description='A player removed protected entities',
color=Colors.yellow,
['Player']='<inline>'..player_name,
['Player']='<inline>'..append_playtime(player_name),
['Entity']='<inline>'..event.entity.name
}
end)
@@ -100,8 +107,8 @@ if config.player_reports then
title='Report',
description='A player was reported',
color=Colors.yellow,
['Player']='<inline>'..player_name,
['By']='<inline>'..by_player_name,
['Player']='<inline>'..append_playtime(player_name),
['By']='<inline>'..append_playtime(by_player_name),
['Report Count']='<inline>'..Reports.count_reports(player_name),
['Reason']=event.reason
}