From 6b1fc786eefb9c32e01bbad2397d5f6fa4616aea Mon Sep 17 00:00:00 2001 From: Tobotimus Date: Mon, 4 Sep 2017 15:49:49 +1000 Subject: [PATCH] [Dev V3] mockmsg command (#928) --- core/dev_commands.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/dev_commands.py b/core/dev_commands.py index 921ff5c08..5cecea56b 100644 --- a/core/dev_commands.py +++ b/core/dev_commands.py @@ -250,3 +250,21 @@ class Dev: ctx.message.author = old_author ctx.message.content = old_content + + @commands.command(name="mockmsg") + @checks.is_owner() + async def mock_msg(self, ctx, user: discord.Member, *, content: str): + """Bot receives a message is if it were sent by a different user. + + Only reads the raw content of the message. Attachments, embeds etc. are ignored.""" + old_author = ctx.author + old_content = ctx.message.content + ctx.message.author = user + ctx.message.content = content + + ctx.bot.dispatch("message", ctx.message) + + await asyncio.sleep(2) # If we change the author and content back too quickly, + # the bot won't process the mocked message in time. + ctx.message.author = old_author + ctx.message.content = old_content