-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(Emoji): create getURL()
function to get more extension of emoji
#8493
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure about this one. This breaks consistency with other url
getters in the library, and if users want to have another extension, they can use client.rest.cdn.emoji(emoji.id, 'jpg')
for example. This function is a shortcut for that, but it breaks consistency, so I don't think it should be added like this.
I agree with thehackerboi that .url should be a getter |
so I have an idea and I don't know if this idea is like you said or not, I can create I hope that you mean. |
Nah i just mean getURL(ext) which will return a url |
ahaa ok i understand now, i will do it |
note: the rest.cdn is automatically throw the error at all |
Codecov Report
@@ Coverage Diff @@
## main #8493 +/- ##
============================================
- Coverage 100.00% 86.54% -13.46%
============================================
Files 2 87 +85
Lines 843 9250 +8407
Branches 159 1854 +1695
============================================
+ Hits 843 8005 +7162
- Misses 0 1189 +1189
- Partials 0 56 +56
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
url()
functiongetURL()
function to get more extension of emoji
/** | ||
* @type {?string} | ||
* @param {ImageExtension} ext the extension of emoji | ||
* @returns {string} | ||
*/ | ||
getURL(ext) { | ||
return this.id && this.client.rest.cdn.emoji(this.id, ext); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the position of this function needs to be below all of the getter methods
/** | |
* @type {?string} | |
* @param {ImageExtension} ext the extension of emoji | |
* @returns {string} | |
*/ | |
getURL(ext) { | |
return this.id && this.client.rest.cdn.emoji(this.id, ext); | |
} | |
/** | |
* @param {ImageExtension} ext the extension of emoji | |
* @returns {?string} | |
*/ | |
getURL(ext) { | |
return this.id && this.client.rest.cdn.emoji(this.id, ext); | |
} |
also corrected documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @type {?string} | |
* @param {ImageExtension} ext the extension of emoji | |
* @returns {string} | |
*/ | |
getURL(ext) { | |
return this.id && this.client.rest.cdn.emoji(this.id, ext); | |
} | |
/** | |
* Returns an emoji url with the specified extension | |
* @param {ImageExtension} ext The extension of the emoji | |
* @returns {?string} | |
*/ | |
getURL(ext) { | |
return this.id && this.client.rest.cdn.emoji(this.id, ext); | |
} |
@@ -1070,6 +1070,7 @@ export class Emoji extends Base { | |||
public name: string | null; | |||
public get identifier(): string; | |||
public get url(): string | null; | |||
public getURL(ext: ImageExtension): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public getURL(ext: ImageExtension): string; | |
public getURL(ext: ImageExtension): string | null; |
as per previous suggestion the method can return null
Superseded by #9788. |
Please describe the changes this PR makes and why it should be merged:
discordjs support only
.gif
and.png
for emoji extension, so I created thegetURL(ext)
function to make the user get any extension of emoji he wants.Status and versioning classification:
Please move lines that apply to you out of the comment: