@@ -846,6 +846,33 @@ async def send_embed(title=None, desc=None):
846846
847847 return blocked
848848
849+ def check_local_git (self ) -> bool :
850+ """
851+ Checks if the bot is installed via git.
852+ """
853+ valid_local_git = False
854+ git_folder_path = os .path .join (".git" )
855+
856+ # Check if the .git folder exists and is a directory
857+ if os .path .exists (git_folder_path ) and os .path .isdir (git_folder_path ):
858+ required_files = ["config" , "HEAD" ]
859+ required_dirs = ["refs" , "objects" ]
860+
861+ # Verify required files exist
862+ for file in required_files :
863+ if not os .path .isfile (os .path .join (git_folder_path , file )):
864+ return valid_local_git
865+
866+ # Verify required directories exist
867+ for directory in required_dirs :
868+ if not os .path .isdir (os .path .join (git_folder_path , directory )):
869+ return valid_local_git
870+
871+ # If all checks pass, set valid_local_git to True
872+ valid_local_git = True
873+
874+ return valid_local_git
875+
849876 async def get_thread_cooldown (self , author : discord .Member ):
850877 thread_cooldown = self .config .get ("thread_cooldown" )
851878 now = discord .utils .utcnow ()
@@ -1711,6 +1738,12 @@ async def before_autoupdate(self):
17111738 self .autoupdate .cancel ()
17121739 return
17131740
1741+ if not self .check_local_git ():
1742+ logger .warning ("Bot not installed via git." )
1743+ logger .warning ("Autoupdates disabled." )
1744+ self .autoupdate .cancel ()
1745+ return
1746+
17141747 @tasks .loop (hours = 1 , reconnect = False )
17151748 async def log_expiry (self ):
17161749 log_expire_after = self .config .get ("log_expiration" )
0 commit comments