Skip to content

Instantly share code, notes, and snippets.

@WardPearce
Last active January 15, 2022 03:32
Show Gist options
  • Save WardPearce/c0401ea17345656ab960793f82046bb6 to your computer and use it in GitHub Desktop.
Save WardPearce/c0401ea17345656ab960793f82046bb6 to your computer and use it in GitHub Desktop.
import sys
import json
import psutil
from os import path
from platform import system
PLATFORM = system()
CHANNELS = [
"", # Stable
"canary",
"ptb",
"development"
]
GOOSEMOD_UPDATE = "https://updates.goosemod.com/goosemod"
GOOSEMOD_NEW_UPDATE = "https://updates.goosemod.com/goosemod/"
if PLATFORM == "Linux":
PATHWAYS = [
"~/.var/app/com.discordapp.Discord/config/discord",
"~/.local/share/flatpak/app/com.discordapp.Discord/config/discord",
"~/.config/discord"
]
elif PLATFORM == "Windows":
PATHWAYS = [
"%/appdata%\discord"
]
elif PLATFORM == "Darwin":
PATHWAYS = [
"~/Library/Application Support/discord"
]
else:
sys.exit("Platform not supported")
process_names = []
for pathway in PATHWAYS:
for channel in CHANNELS:
settings_path = path.join(
path.expanduser(pathway + channel),
"settings.json"
)
if path.exists(settings_path):
with open(settings_path) as settings:
json_data = json.load(settings)
json_data["UPDATE_ENDPOINT"] = GOOSEMOD_UPDATE
json_data["NEW_UPDATE_ENDPOINT"] = GOOSEMOD_NEW_UPDATE
with open(settings_path, "w") as settings:
settings.write(json.dumps(json_data, indent=4, sort_keys=True))
process_names.append("Discord" + channel.capitalize())
for proc in psutil.process_iter():
if proc.name() in process_names:
proc.kill()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment