Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Glitch?] allowed_mentions ignored for short duration #9781

Open
ItsCubeTime opened this issue Apr 9, 2024 · 4 comments
Open

[Glitch?] allowed_mentions ignored for short duration #9781

ItsCubeTime opened this issue Apr 9, 2024 · 4 comments
Labels
unconfirmed bug A bug report that needs triaging

Comments

@ItsCubeTime
Copy link

ItsCubeTime commented Apr 9, 2024

Core issue:

I havent been able to reproduce this, but this morning one of our Bots using discordpy mentioned @everyone with a message sent using the statements:

...
allowed_mentions = discord.AllowedMentions(everyone=False, users=True, roles=False,replied_user=True)

responsemsg = await message.reply(f"{prefix}{part}", allowed_mentions=allowed_mentions)

(Where f"{prefix}{part}" contained the substring "@everyone")

So far we havent been able to reproduce the issue, but 4 mentions was sent within a couple of minutes before the glitch seemed to go away on its own (as we were testing a couple of hours later, messages sent using the same code would not result in a ping, a lot of users in the server also tried to send more pings after the first ones were sent, but for some reason only 4 out of the pings actually resulted in a mention of @everyone

Additional Info:

The bot that exhibited the bug was an AI chatbot that would respond to user prompts - and around 20 users were essentially using it to try and spam everyone on the server for a couple of hours. Only 4 pings went through however.

In case its to any use, I have a time tracked log of all the user sent requests (filtered by messages containing the substring 'everyone'). It might give an idea as to when the glitch was active.
AiPromptsAllMessagesToday.txt
)

Our bot is running on:
Python verson: 3.12.2
discordpy version: 2.3.2
(and some Linux based distro)

@ItsCubeTime ItsCubeTime added the unconfirmed bug A bug report that needs triaging label Apr 9, 2024
@AbstractUmbra
Copy link
Contributor

Hello,

AllowedMentions are handled Discord side.

What I mean by this is that we only send the AllowedMentions object alongside the request to create the message (more on the parameters).

This means that parsing the message content for this and disallowing it is done on Discord's API side, not within d.py.

If your code is actually what you have shown then we have done everything we can for AllowedMentions in sending.
I can't imagine the API will suddenly stop respecting this key in the payload so I would advise you to peer over your codebase for places that you respond and explicitly disallow it.

Alternative solutions are:

  • Setting AllowedMentions (the allowed_mentions kwarg) in the Bot constructor, explicitly overriding where necessary.
  • Disable the capability for the bot to send @everyone regardless.

@ItsCubeTime
Copy link
Author

Just a food for thought, would it be possible that some of the messages sent to discords API got cut-off - omitting the allowed_mentions flag (not that that would explain how 4 messages in a row were able to go through)?

And yes, we are now manually reading the respond string, removing any mentions ourselves

@AbstractUmbra
Copy link
Contributor

Definitely not, they are part of a json body and the allowed_mentions key is separate.

I'd still recommend one of the alternate solutions over manual intervention, but that's up to you.

@ItsCubeTime
Copy link
Author

Alright, thanks for taking the time @AbstractUmbra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants