-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(Sticker): updates, sticker packs, and guild stickers #5867
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
23ce3c3
feat(Sticker): update sticker properties
advaith1 61c09c7
feat: add StickerPack
advaith1 9cc3e87
feat(Sticker): add fetchPack()
advaith1 dd810cf
types: fix order
advaith1 059964c
use client.guilds.resolve
advaith1 ac897e5
fix: rename StickerBanner to StickerPackBanner
advaith1 afa882b
feat(Client): add fetchSticker(id)
advaith1 ee953d9
Edit fetchSticker desc
advaith1 3545ca2
style: switch from .then to async/await
advaith1 2e84a12
style: use data variables instead of inline API reqs
advaith1 8f3c562
refactor: move sticker url to CDN constant
advaith1 58c95e3
refactor: rename fetchNitroStickerPacks to fetchPremiumStickerPacks
advaith1 b7f0fc8
refactor(Permissions): `MANAGE_EMOJIS_AND_STICKERS`
advaith1 f1c8f19
fix(StickerPack): `cover_sticker_id` is optional
advaith1 3814ef3
fix: banner fields are not nullable
advaith1 7dd8a60
refactor: switch to msg.sticker_items, add fetch() and fetchUser()
advaith1 16c21cb
Apply suggestions from code review
advaith1 c65a377
types: switch to old nullable syntax
advaith1 55abf97
fix partial check
advaith1 6c9f2be
Apply suggestions from code review
advaith1 a761659
fix: partial check but for real this time
advaith1 d97cdd0
Merge remote-tracking branch 'upstream/master' into sticker-updates
advaith1 a08b490
feat: sending stickers
advaith1 594ba64
feat: add GuildStickerManager and events
advaith1 ddc9b54
Apply suggestions from code review
advaith1 af64a00
Merge branch 'master' into sticker-updates
advaith1 a7bb38e
fix(GuildStickerManager): crawl missed an `ID`
advaith1 dbce477
fix(Sticker): check tags in API equals
advaith1 61fc74e
types: add typings for GSM and events
advaith1 c202904
fix(GuildStickerManager): extend CachedManager
advaith1 e95ec9a
Merge branch 'master' into sticker-updates
advaith1 ced9bf3
feat(ApiErrors): add sticker error codes
advaith1 41fb4bb
feat(GuildAuditLogs): add sticker audit logs
advaith1 54133d3
style: use for-of and object.entries
advaith1 eca5e4d
Merge branch 'master' into sticker-updates
advaith1 60ae9ff
style: use optional chaining
advaith1 31ca245
style: return new collection directly
advaith1 8193e0f
feat(Permissions): add USE_EXTERNAL_STICKERS
advaith1 a3b9a52
feat(ApiErrors): add 170007
advaith1 737ed2b
Merge branch 'master' into sticker-updates
advaith1 e26591b
refactor: rename add to _add
advaith1 8a6cb78
feat: support old messages and edit Message#stickers desc
advaith1 8a32e87
Merge branch 'master' into sticker-updates
advaith1 d17fe5d
feat: add more error codes
advaith1 c98dda1
fix: missed one `add`
advaith1 5ab68fc
docs: sticker object API docs links and API types
advaith1 e5023ed
Merge branch 'master' into sticker-updates
advaith1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| 'use strict'; | ||
|
|
||
| const Base = require('./Base'); | ||
| const Sticker = require('./Sticker'); | ||
| const Collection = require('../util/Collection'); | ||
| const SnowflakeUtil = require('../util/SnowflakeUtil'); | ||
|
|
||
| /** | ||
| * Represents a pack of standard stickers. | ||
| * @extends {Base} | ||
| */ | ||
| class StickerPack extends Base { | ||
| /** | ||
| * @param {Client} client The instantiating client | ||
| * @param {Object} pack The data for the sticker pack | ||
iCrawl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| constructor(client, pack) { | ||
| super(client); | ||
| /** | ||
| * The ID of the sticker pack | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @type {Snowflake} | ||
| */ | ||
| this.id = pack.id; | ||
|
|
||
| /** | ||
| * The stickers in the pack | ||
| * @type {Collection<Snowflake, Sticker>} | ||
| */ | ||
| this.stickers = new Collection(pack.stickers.map(s => [s.id, new Sticker(client, s)])); | ||
iCrawl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * The name of the sticker pack | ||
| * @type {string} | ||
| */ | ||
| this.name = pack.name; | ||
|
|
||
| /** | ||
| * The ID of the pack's SKU | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @type {Snowflake} | ||
| */ | ||
| this.skuID = pack.sku_id; | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * The ID of a sticker in the pack which is shown as the pack's icon | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @type {Snowflake} | ||
| */ | ||
| this.coverStickerID = pack.cover_sticker_id; | ||
|
|
||
| /** | ||
| * The description of the sticker pack | ||
| * @type {string} | ||
| */ | ||
| this.description = pack.description; | ||
|
|
||
| /** | ||
| * The ID of the sticker pack's banner image | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @type {?Snowflake} | ||
| */ | ||
| this.bannerID = pack.banner_asset_id; | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * The timestamp the sticker was created at | ||
| * @type {number} | ||
| * @readonly | ||
| */ | ||
| get createdTimestamp() { | ||
| return SnowflakeUtil.deconstruct(this.id).timestamp; | ||
| } | ||
|
|
||
| /** | ||
| * The time the sticker was created at | ||
| * @type {Date} | ||
| * @readonly | ||
| */ | ||
| get createdAt() { | ||
| return new Date(this.createdTimestamp); | ||
| } | ||
|
|
||
| /** | ||
| * The sticker which is shown as the pack's icon | ||
| * @type {Sticker} | ||
| * @readonly | ||
| */ | ||
| get coverSticker() { | ||
| return this.stickers.get(this.coverStickerID); | ||
| } | ||
|
|
||
| /** | ||
| * The URL to this sticker pack's banner. | ||
| * @param {StaticImageURLOptions} [options={}] Options for the Image URL | ||
| * @returns {?string} | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| bannerURL({ format, size } = {}) { | ||
| return this.client.rest.cdn.StickerPackBanner(this.bannerID, format, size); | ||
advaith1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| module.exports = StickerPack; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.