Adds Configurable Living Time Requirement to Discord Auto Enrollment (#50052)

About The Pull Request

As requested by oranges this enforces a requirement, when configured, that a player must have a certain amount of living playtime in hours to auto-enroll into a discord role.
Why It's Good For The Game

Removes discord moderation requirement
Changelog

cl bobbahbrown
server: Discord role auto enrollment can now be configured to require a certain number of living hours.
/cl
This commit is contained in:
Bobbahbrown
2020-03-20 21:09:16 +13:00
committed by GitHub
parent 9459176cad
commit fdcbc8cd83
6 changed files with 39 additions and 18 deletions
+14 -9
View File
@@ -30,16 +30,22 @@ SUBSYSTEM_DEF(discord)
wait = 3000
init_order = INIT_ORDER_DISCORD
var/list/notify_members = list() // People to save to notify file
var/list/notify_members_cache = list() // Copy of previous list, so the SS doesnt have to fire if no new members have been added
var/list/people_to_notify = list() // People to notify on roundstart
var/list/account_link_cache = list() // List that holds accounts to link, used in conjunction with TGS
var/list/reverify_cache = list() // list of people who tried to reverify, so they can only do it once per round as a shitty slowdown
/// People to save to notify file
var/list/notify_members = list()
/// Copy of previous list, so the SS doesnt have to fire if no new members have been added
var/list/notify_members_cache = list()
/// People to notify on roundstart
var/list/people_to_notify = list()
/// List that holds accounts to link, used in conjunction with TGS
var/list/account_link_cache = list()
/// list of people who tried to reverify, so they can only do it once per round as a shitty slowdown
var/list/reverify_cache = list()
var/notify_file = file("data/notify.json")
var/enabled = 0 // Is TGS enabled (If not we wont fire because otherwise this is useless)
/// Is TGS enabled (If not we wont fire because otherwise this is useless)
var/enabled = 0
/datum/controller/subsystem/discord/Initialize(start_timeofday)
// Check for if we are using TGS, otherwise return and disabless firing
// Check for if we are using TGS, otherwise return and disables firing
if(world.TgsAvailable())
enabled = 1 // Allows other procs to use this (Account linking, etc)
else
@@ -49,7 +55,7 @@ SUBSYSTEM_DEF(discord)
try
people_to_notify = json_decode(file2text(notify_file))
catch
pass() // The list can just stay as its defualt (blank). Pass() exists because it needs a catch
pass() // The list can just stay as its default (blank). Pass() exists because it needs a catch
var/notifymsg = ""
for(var/id in people_to_notify)
// I would use jointext here, but I dont think you can two-side glue with it, and I would have to strip characters otherwise
@@ -123,7 +129,6 @@ SUBSYSTEM_DEF(discord)
var/url = "https://discordapp.com/api/guilds/[CONFIG_GET(string/discord_guildid)]/members/[id]/roles/[CONFIG_GET(string/discord_roleid)]"
// Make the request
var/datum/http_request/req = new()
req.prepare(RUSTG_HTTP_METHOD_PUT, url, "", list("Authorization" = "Bot [CONFIG_GET(string/discord_token)]"))
req.begin_async()