@staticmethod
PYL-R020113 self.bot = bot
14 self.tts = aiogTTS()
15
16 async def to_bytes(self, url):17 async with bot.session.get(url) as r:
18 res = await r.read()
19 return res
8 self.bot = bot
9 self._last_result = None
10
11 def cleanup_code(self, content):12 """Automatically removes code blocks from the code."""
13 if content.startswith("```") and content.endswith("```"):
14 return "\n".join(content.split("\n")[1:-1])
305 async def cog_before_invoke(self, ctx: commands.Context):
306 ctx.voice_state = self.get_voice_state(ctx)
307
308 async def cog_command_error(309 self, ctx: commands.Context, error: commands.CommandError
310 ):
311 await ctx.send("An error occurred: {}".format(str(error)))
294 for state in self.voice_states.values():
295 self.bot.loop.create_task(state.stop())
296
297 def cog_check(self, ctx: commands.Context):298 if not ctx.guild:
299 raise commands.NoPrivateMessage(
300 "This command can't be used in DM channels."
15 def __init__(self, bot):
16 self.bot = bot
17
18 def sanitize(self, mat):19 """Sanitize input with the best-in-class algorithm to prevent abuse"""
20 to_remove = ["self", '"', "'", "import", "prototype", "proto"]
21
The method doesn't use its bound instance. Decorate this method with @staticmethod
decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods here.