Discord.py requests unable to block pings in webhooks

  discord.py, python, python-requests, webhooks

I’ve been trying to find a way to disable @everyone pings working in webhooks. I’ve managed to do so fine with normal responses (not via webhooks), however when I attempt to do so with a webhook, it returns an error. Here’s my code:

@bot.command()
async def webhook(ctx):
    Message = {
        "content": f"Hey @everyone"
    }
    am = discord.AllowedMentions(
            everyone=False,
        )
    requests.post(url="MY WEBHOOK URL", data=Message, allowed_mentions=am)

And this is the error I receive:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: request() got an unexpected keyword argument 'allowed_mentions'

Is there a way for the mentions to be disabled in webhooks posted via requests.post? Thank you!

Source: Python Questions

LEAVE A COMMENT