1
1
import sys
2
2
import time
3
3
import json
4
+ import shutil
4
5
import logging
5
6
import requests
6
7
from funcs import *
@@ -29,6 +30,7 @@ def dump_settings():
29
30
logger = logging .getLogger (__name__ )
30
31
logging .basicConfig (level = logging .INFO , format = '(%(asctime)s) %(message)s' )
31
32
appdata = os .getenv ('appdata' )
33
+ home = os .getenv ('userprofile' )
32
34
localappdata = os .getenv ('localappdata' )
33
35
34
36
SETTINGS_PATH = 'settings.json'
@@ -39,10 +41,16 @@ def dump_settings():
39
41
40
42
# default settings
41
43
CURRENT_SETTINGS_VERSION = 3
42
- DISCORD_PARENT_PATH = f'{ localappdata } / Discord'
44
+ DISCORD_PARENT_PATH = f'{ localappdata } \\ Discord'
43
45
LAST_INSTALLED_DISCORD_VERSION = None
44
46
DISABLE_VERSION_CHECKING = False
45
47
48
+ if shutil .which ('scoop' ) is not None :
49
+ scoop_info = subprocess .run (['scoop' , 'list' , 'discord' ], capture_output = True , text = True , shell = True ).stdout .splitlines ()
50
+ discord_line = next ((line for line in scoop_info if line .startswith ('discord ' )), None )
51
+ if discord_line :
52
+ DISCORD_PARENT_PATH = f'{ home } \\ scoop\\ apps\\ discord\\ current\\ app'
53
+
46
54
# try to load settings
47
55
if os .path .exists (SETTINGS_PATH ):
48
56
try :
@@ -60,8 +68,8 @@ def dump_settings():
60
68
61
69
# get discord location from user if it is invalid
62
70
while True :
63
- if not os .path .exists (os .path .join (DISCORD_PARENT_PATH , 'update .exe' )):
64
- logger .info (f'Discord was not found at "{ DISCORD_PARENT_PATH } ". Enter the path to folder with "Update.exe":' )
71
+ if not os .path .exists (os .path .join (DISCORD_PARENT_PATH , 'Update.exe' )) and not os . path . exists ( os . path . join ( discord_path , 'Discord .exe' )):
72
+ logger .info (f'Discord was not found at "{ DISCORD_PARENT_PATH } ".\n Enter the path to folder with "Update.exe" for normal installations or full path of ~ \\ scoop \\ apps \\ discord \\ current \\ app for scoop installations :' )
65
73
DISCORD_PARENT_PATH = input ('\n => ' )
66
74
dump_settings ()
67
75
else :
0 commit comments