-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add Guild.acronym #10080
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
Add Guild.acronym #10080
Conversation
I have two main issues with this.
- The current implementation wastes memory for those who do not care about this feature (i.e. most people)
- The current implementation feels dodgy. It's using regex for no good reason and expensively so, it seems like it's a 1:1 port of JS code without porting it to the target language's strength.
Other than that I'm not sure on the overall merit of the PR. Is this a commonly requested feature? If you do a simple search of nameAcronym on GitHub you don't get that many results of people actually using it.
I have two main issues with this.
- The current implementation wastes memory for those who do not care about this feature (i.e. most people)
- The current implementation feels dodgy. It's using regex for no good reason and expensively so, it seems like it's a 1:1 port of JS code without porting it to the target language's strength.
Other than that I'm not sure on the overall merit of the PR. Is this a commonly requested feature? If you do a simple search of
nameAcronymon GitHub you don't get that many results of people actually using it.
1 & 2. Fair points. Unfortunately, I don't know how to fix that, as I am very new to regex usage. Reviews are welcome.
This is not a requested feature, but I thought it would fit in between the other features, as others pointed out, like Message.system_content, Member.top_role, etc.
3717ed6 to
8953938
Compare
From what I understood, I believe ''.join(word[0] for word in self.name.split()) suffices as a way without regex?
From what I understood, I believe
''.join(word[0] for word in self.name.split())suffices as a way without regex?
Unfortunately not, there are edge cases that apply to this, such as "X of Y" and "X's thing".
It's a bit more involved.
Unfortunately not, there are edge cases that apply to this, such as "X of Y" and "X's thing".
It's a bit more involved.
Interesting, I just tested the examples you gave on both my mobile and desktop client, and they show up as "XoY" and "Xt", respectively. I ran my code snippet and it did get it right.
Uh oh!
There was an error while loading. Please reload this page.
Summary
This PR adds an
acronymproperty to Guild that returns the characters that show up when a server has no icon set.The property returns a cached version (
_acronym) since it rarely, if ever, changes.I got this idea from the discord.js library. I have converted it to Python as is.
Discussion post: https://canary.discord.com/channels/336642139381301249/1279035934192439388
Checklist