@@ -758,6 +758,33 @@ def check_manual_blocked(self, author: discord.Member) -> bool:
758758 logger .debug ("User blocked, user %s." , author .name )
759759 return False
760760
761+ def check_local_git (self ) -> bool :
762+ """
763+ Checks if the bot is installed via git.
764+ """
765+ valid_local_git = False
766+ git_folder_path = os .path .join (".git" )
767+
768+ # Check if the .git folder exists and is a directory
769+ if os .path .exists (git_folder_path ) and os .path .isdir (git_folder_path ):
770+ required_files = ["config" , "HEAD" ]
771+ required_dirs = ["refs" , "objects" ]
772+
773+ # Verify required files exist
774+ for file in required_files :
775+ if not os .path .isfile (os .path .join (git_folder_path , file )):
776+ return valid_local_git
777+
778+ # Verify required directories exist
779+ for directory in required_dirs :
780+ if not os .path .isdir (os .path .join (git_folder_path , directory )):
781+ return valid_local_git
782+
783+ # If all checks pass, set valid_local_git to True
784+ valid_local_git = True
785+
786+ return valid_local_git
787+
761788 async def _process_blocked (self , message ):
762789 _ , blocked_emoji = await self .retrieve_emoji ()
763790 if await self .is_blocked (message .author , channel = message .channel , send_message = True ):
@@ -1721,6 +1748,12 @@ async def before_autoupdate(self):
17211748 self .autoupdate .cancel ()
17221749 return
17231750
1751+ if not self .check_local_git ():
1752+ logger .warning ("Bot not installed via git." )
1753+ logger .warning ("Autoupdates disabled." )
1754+ self .autoupdate .cancel ()
1755+ return
1756+
17241757 @tasks .loop (hours = 1 , reconnect = False )
17251758 async def log_expiry (self ):
17261759 log_expire_after = self .config .get ("log_expiration" )
0 commit comments