async def exec(self, ctx, *, code): """Remote executes code.""" code = code.strip() py_start = code.lower().startswith("```py") python_start = py_start and code.lower().startswith("```python") view = StringView(code) view.skip_string(ctx.prefix) view.skip_ws() view.skip_string(ctx.invoked_with) view.skip_ws() code = view.read_rest() if python_start: code = code[9:] elif py_start: code = code[5:] elif code.startswith("```"): code = code[3:] if code.endswith("```"): code = code[:-3] del py_start, python_start, view with closing(StringIO()) as log: with redirect_stdout(log): try: exec(code) except Exception: error = exc_info() for e in error: print(e) output = log.getvalue() output = "```\n" + output + "```" await reply(ctx, output)
def add_message(self, message): view = StringView(message.content) command = view.get_word() request_data = { "message_id": str(message.id), "user_id": str(message.author.id), "server_id": str(message.guild.id), "command": command, "content": view.read_rest(), "timestamp": message.created_at } try: self.firestore.collection('requests').add( document_data=request_data, document_id=str(message.id)) except Conflict as e: logger.error(e)