mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Merge pull request #1125 from grilledham/reports-ping-channel
Reports ping channel
This commit is contained in:
commit
c35909cf46
@ -6,6 +6,12 @@ local Command = require 'utils.command'
|
||||
local Popup = require 'features.gui.popup'
|
||||
local Color = require 'resources.color_presets'
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'features.server'
|
||||
local Discord = require 'resources.discord'
|
||||
|
||||
local helpdesk_channel = Discord.channel_names.helpdesk
|
||||
local moderation_log_channel = Discord.channel_names.moderation_log
|
||||
local moderator_role_mention = Discord.role_mentions.moderator
|
||||
|
||||
local format = string.format
|
||||
|
||||
@ -143,6 +149,29 @@ Module.show_reports = function(player)
|
||||
draw_report(report_body, #reports)
|
||||
end
|
||||
|
||||
local function send_report_to_discord(reporting_player, reported_player, message)
|
||||
local text = {}
|
||||
if reporting_player and reporting_player.valid then
|
||||
text[#text + 1] = reporting_player.name
|
||||
else
|
||||
text[#text + 1] = '<script>'
|
||||
end
|
||||
|
||||
text[#text + 1] = ' reported '
|
||||
text[#text + 1] = reported_player.name
|
||||
text[#text + 1] = ' - game time '
|
||||
text[#text + 1] = Utils.format_time(game.tick)
|
||||
text[#text + 1] = ':\\n\\n'
|
||||
text[#text + 1] = message
|
||||
|
||||
text = table.concat(text)
|
||||
|
||||
Server.to_discord_named_embed(helpdesk_channel, text)
|
||||
Server.to_discord_named_raw(helpdesk_channel, moderator_role_mention)
|
||||
|
||||
Server.to_discord_named_embed(moderation_log_channel, text)
|
||||
end
|
||||
|
||||
function Module.report(reporting_player, reported_player, message)
|
||||
local player_index
|
||||
if reporting_player then
|
||||
@ -156,6 +185,8 @@ function Module.report(reporting_player, reported_player, message)
|
||||
tick = game.tick
|
||||
})
|
||||
|
||||
send_report_to_discord(reporting_player, reported_player, message)
|
||||
|
||||
local notified = false
|
||||
for _, p in pairs(game.players) do
|
||||
if p.admin and p.connected then
|
||||
@ -175,6 +206,17 @@ function Module.report(reporting_player, reported_player, message)
|
||||
end
|
||||
end
|
||||
|
||||
local function send_jail_to_discord(target_player, player)
|
||||
local message = table.concat {
|
||||
target_player.name,
|
||||
' has been jailed by ',
|
||||
player.name,
|
||||
' - game time ',
|
||||
Utils.format_time(game.tick)
|
||||
}
|
||||
Server.to_discord_named_embed(moderation_log_channel, message)
|
||||
end
|
||||
|
||||
--- Places a target in jail
|
||||
-- @param target_player <LuaPlayer> the target to jail
|
||||
-- @param player <LuaPlayer|nil> the admin as LuaPlayer or server as nil
|
||||
@ -274,6 +316,8 @@ function Module.jail(target_player, player)
|
||||
|
||||
target_player.color = Color.white
|
||||
target_player.chat_color = Color.white
|
||||
|
||||
send_jail_to_discord(target_player, player)
|
||||
else
|
||||
-- Let admin know it didn't work.
|
||||
print(format('Something went wrong in the jailing of %s. You can still change their group via /permissions.',
|
||||
|
@ -12,10 +12,13 @@ local Core = require 'utils.core'
|
||||
local Color = require 'resources.color_presets'
|
||||
local Toast = require 'features.gui.toast'
|
||||
local Utils = require 'utils.core'
|
||||
local DiscordChannelNames = require 'resources.discord_channel_names'
|
||||
local Discord = require 'resources.discord'
|
||||
local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
local ScoreTracker = require 'utils.score_tracker'
|
||||
|
||||
local map_promotion_channel = Discord.channel_names.map_promotion
|
||||
local crash_site_role_mention = Discord.role_mentions.crash_site
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.control(config)
|
||||
@ -86,9 +89,7 @@ function Public.control(config)
|
||||
return
|
||||
elseif state == 1 then
|
||||
local time_string = Core.format_time(game.ticks_played)
|
||||
local discord_crashsite_role = '<@&762441731194748958>' -- @crash_site
|
||||
-- local discord_crashsite_role = '<@&593534612051984431>' -- @test
|
||||
Server.to_discord_named_raw(DiscordChannelNames.map_promotion, discord_crashsite_role
|
||||
Server.to_discord_named_raw(map_promotion_channel, crash_site_role_mention
|
||||
.. ' **Crash Site has just restarted! Previous map lasted: ' .. time_string .. '!**')
|
||||
|
||||
local end_epoch = Server.get_current_time()
|
||||
|
18
resources/discord.lua
Normal file
18
resources/discord.lua
Normal file
@ -0,0 +1,18 @@
|
||||
--- Resources for use in interacting with discord.
|
||||
return {
|
||||
--- The names of the discord channels that can be referenced by name.
|
||||
-- See features.server.to_discord_named
|
||||
channel_names = {
|
||||
bot_playground = 'bot-playground',
|
||||
map_promotion = 'map-promotion',
|
||||
moderation_log = 'moderation-log',
|
||||
helpdesk = 'helpdesk'
|
||||
},
|
||||
--- The strings that mention the discord role.
|
||||
-- Has to be used with features.server.to_discord_raw variants else the mention is sanitized server side.
|
||||
role_mentions = {
|
||||
test = '<@&593534612051984431>',
|
||||
crash_site = '<@&762441731194748958>',
|
||||
moderator = '<@&454192594633883658>'
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
--- The names of the discord channels that can be referenced by name.
|
||||
-- See features.server.to_discord_named
|
||||
return {
|
||||
map_promotion = 'map-promotion'
|
||||
}
|
Loading…
Reference in New Issue
Block a user