Files
Bubberstation/code/modules/discord/toggle_notify.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

35 lines
1.6 KiB
Plaintext

// Verb to toggle restart notifications
/client/verb/notify_restart()
set category = "OOC"
set name = "Notify Restart"
set desc = "Notifies you on Discord when the server restarts."
// Safety checks
if(!CONFIG_GET(flag/sql_enabled))
to_chat(src, span_warning("This feature requires the SQL backend to be running."))
return
if(!SSdiscord) // SS is still starting
to_chat(src, span_notice("The server is still starting up. Please wait before attempting to link your account "))
return
if(!SSdiscord.enabled)
to_chat(src, span_warning("This feature requires the server is running on the TGS toolkit"))
return
var/stored_id = SSdiscord.lookup_id(usr.ckey)
if(!stored_id) // Account is not linked
to_chat(src, span_warning("This requires you to link your Discord account with the \"Link Discord Account\" verb."))
return
else // Linked
for(var/member in SSdiscord.notify_members) // If they are in the list, take them out
if(member == "[stored_id]")
SSdiscord.notify_members -= "[stored_id]" // The list uses strings because BYOND cannot handle a 17 digit integer
to_chat(src, span_notice("You will no longer be notified when the server restarts"))
return // This is necassary so it doesnt get added again, as it relies on the for loop being unsuccessful to tell us if they are in the list or not
// If we got here, they arent in the list. Chuck 'em in!
to_chat(src, span_notice("You will now be notified when the server restarts"))
SSdiscord.notify_members += "[stored_id]" // The list uses strings because BYOND cannot handle a 17 digit integer