From bda61e3adad8ef282aa60004b473896589a7f02b Mon Sep 17 00:00:00 2001 From: bobloy Date: Mon, 3 Aug 2020 15:35:34 -0400 Subject: [PATCH] Handle permission errors --- chatter/chat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chatter/chat.py b/chatter/chat.py index 43c6ebe..f7e8944 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -179,7 +179,10 @@ class Chatter(Cog): 10 ) # Pause to allow pending commands to complete before deleting sql data if os.path.isfile(self.data_path): - os.remove(self.data_path) + try: + os.remove(self.data_path) + except PermissionError: + await ctx.maybe_send_embed("Failed to clear training database. Please wait a bit and try again") self._create_chatbot(self.data_path, SpacySimilarity, 0.45, ENG_MD)