Twentysix26 / x26-Cogs

General purpose cogs for Red V3
GNU General Public License v3.0
41 stars 30 forks source link

[Bug] Add display-name-matches-any Condition #83

Closed EternalllZM closed 2 months ago

EternalllZM commented 4 months ago

Cog

Describe the bug Any nickname-matches-any condition simply does not return true even if there are examples of nicknames that should return true.

To Reproduce Steps to reproduce the behavior:

  1. Create a rule with nickname-matches-any
  2. Try to match a basic nickname
  3. It does not work

Expected behavior This condition last worked prior to discord updating usernames, that or Red 3.5, those were around the same time.

username-matches-any works just fine from my last test.

Screenshots N/A

DoctorDinosaur commented 2 months ago

It's working for me.

nickname-matches-any only matches for if a user has a nickname

image

Do you wanna use if-any with both checking nickname and username? https://twentysix26.github.io/defender-docs/warden/overview/#defining-a-more-complex-rule

EternalllZM commented 2 months ago

It may be an issue of needing a displayname-matches-any: condition. When usernames were changed I believe you were given the option to set a username and a display name. This display name cannot be queried using any existing warden condition. None of my de-hoisting rules work because the ! <name> is neither their username nor a set server-based nickname.

EternalllZM commented 2 months ago

Example of an account with this username/DN difference here image

This is the root condition of the dehoist rule, which should be TRUE on this profile, yet nothing happens.

if:
  - if-any:
    - nickname-matches-any: ['!*', "'*", '"*']
    - username-matches-any: ['!*', "'*", '"*']
Twentysix26 commented 2 months ago

I can't seem to reproduce this issue

When usernames were changed I believe you were given the option to set a username and a display name. This display name cannot be queried using any existing warden condition

I'm not sure what you mean here. To clarify the terminology: "nickname" is the server specific name that you can set in your server profile. In Discord's UI it takes precedence over your global username. "username", or just "name", is your global username. If you don't have a nickname, you show up as that. "display name", in the context of discord.py, means either the server nickname (if one is present) OR the global username.

Now, I'm partial to adding a display-name-matches-any as I recognize it would be useful to avoid repetition.
FYI this is already kinda doable with compare and the $user_display context variable, you'd be missing the convenience of passing a list of possible names though.

DoctorDinosaur commented 2 months ago

Added a check for the global display name in #87, but some combinatory "name-matches-any" which does username, global display name, and server nickname, might be less of a ballache.

It's what most people want, instead of having do do an if-any with three conds

DoctorDinosaur commented 2 months ago

I'm not sure what you mean here. To clarify the terminology: "nickname" is the server specific name that you can set in your server profile. In Discord's UI it takes precedence over your global username. "username", or just "name", is your global username. If you don't have a nickname, you show up as that. "display name", in the context of discord.py, means either the server nickname (if one is present) OR the global username.

There's all three: Username: The replacement for username#discriminator Display Name: A global nickname, shows up instead where available Nickname: Server specific nickname

image

Twentysix26 commented 2 months ago

@EternalllZM Ah I see what you meant with global name now. Ty @DoctorDinosaur. A display-name-matches-any is definitely needed now.

EternalllZM commented 2 months ago

Fixed title. Apologies for the inadequate description and confusion surrounding the issue. I wasn't familiar with what discord.py called it in their docs.

EternalllZM commented 2 months ago

Tested and verified fixed by 483150f