156
157 def add_filtered_word(self, fw: FilterWord) -> None:
158 existing = self.get_guild().filter_words.filter(word=fw.word)
159 if(len(existing) > 0):160 return False
161
162 Guild.objects(_id=cfg.guild_id).update_one(push__filter_words=fw)
141
142 def add_raid_phrase(self, phrase: str) -> bool:
143 existing = self.get_guild().raid_phrases.filter(word=phrase)
144 if(len(existing) > 0):145 return False
146 Guild.objects(_id=cfg.guild_id).update_one(push__raid_phrases=FilterWord(word=phrase, bypass=5, notify=True))
147 return True
127 pattern = re.compile(
128 r"(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))")
129 link = pattern.search(msg.content)
130 if (link):131 if link.group(0):
132 link = link.group(0)
133
1037 formatted_error = traceback.format_exc()
1038 if str(error) == loc["error"]["no_pm"]:
1039 return await ctx.send(loc["error"]["no_pm"])
1040 if not (str(error) == "Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'is_finished'"):1041 await ctx.send(loc["error"]["error_msg"].format(str(error)))
1042 if hasattr(ctx, "voice_state") and ctx.voice_state:
1043 if ctx.voice_state.debug["debug_log"]:
Extra parentheses in code can be removed for improved readability.
In the examples below, the first example is more readable than the second one.
Preferred:
if len(some_variable) + 1 < 1:
...
Not preferred:
if (len(some_variable) + 1) < 1:
...