-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(WelcomeScreen): welcome screens (#5490)
Co-authored-by: Jan <[email protected]> Co-authored-by: izexi <[email protected]> Co-authored-by: SpaceEEC <[email protected]> Co-authored-by: Vlad Frangu <[email protected]>
- Loading branch information
1 parent
807ea2d
commit 44e2ee7
Showing
11 changed files
with
342 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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 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,78 @@ | ||
'use strict'; | ||
|
||
const BaseGuild = require('./BaseGuild'); | ||
const { VerificationLevels, NSFWLevels } = require('../util/Constants'); | ||
|
||
/** | ||
* Bundles common attributes and methods between {@link Guild} and {@link InviteGuild} | ||
* @abstract | ||
*/ | ||
class AnonymousGuild extends BaseGuild { | ||
constructor(client, data) { | ||
super(client, data); | ||
this._patch(data); | ||
} | ||
|
||
_patch(data) { | ||
this.features = data.features; | ||
/** | ||
* The hash of the guild invite splash image | ||
* @type {?string} | ||
*/ | ||
this.splash = data.splash; | ||
|
||
/** | ||
* The hash of the guild banner | ||
* @type {?string} | ||
*/ | ||
this.banner = data.banner; | ||
|
||
/** | ||
* The description of the guild, if any | ||
* @type {?string} | ||
*/ | ||
this.description = data.description; | ||
|
||
/** | ||
* The verification level of the guild | ||
* @type {VerificationLevel} | ||
*/ | ||
this.verificationLevel = VerificationLevels[data.verification_level]; | ||
|
||
/** | ||
* The vanity invite code of the guild, if any | ||
* @type {?string} | ||
*/ | ||
this.vanityURLCode = data.vanity_url_code; | ||
|
||
if ('nsfw_level' in data) { | ||
/** | ||
* The NSFW level of this guild | ||
* @type {NSFWLevel} | ||
*/ | ||
this.nsfwLevel = NSFWLevels[data.nsfw_level]; | ||
} | ||
} | ||
|
||
/** | ||
* The URL to this guild's banner. | ||
* @param {ImageURLOptions} [options={}] Options for the Image URL | ||
* @returns {?string} | ||
*/ | ||
bannerURL({ format, size } = {}) { | ||
if (!this.banner) return null; | ||
return this.client.rest.cdn.Banner(this.id, this.banner, format, size); | ||
} | ||
|
||
/** | ||
* The URL to this guild's invite splash image. | ||
* @param {ImageURLOptions} [options={}] Options for the Image URL | ||
* @returns {?string} | ||
*/ | ||
splashURL({ format, size } = {}) { | ||
if (!this.splash) return null; | ||
return this.client.rest.cdn.Splash(this.id, this.splash, format, size); | ||
} | ||
} | ||
|
||
module.exports = AnonymousGuild; |
This file contains 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 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 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 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 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 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,23 @@ | ||
'use strict'; | ||
|
||
const AnonymousGuild = require('./AnonymousGuild'); | ||
const WelcomeScreen = require('./WelcomeScreen'); | ||
|
||
/** | ||
* Represents a guild received from an invite, includes welcome screen data if available. | ||
* @extends {AnonymousGuild} | ||
*/ | ||
class InviteGuild extends AnonymousGuild { | ||
constructor(client, data) { | ||
super(client, data); | ||
|
||
/** | ||
* The welcome screen for this invite guild | ||
* @type {?WelcomeScreen} | ||
*/ | ||
this.welcomeScreen = | ||
typeof data.welcome_screen !== 'undefined' ? new WelcomeScreen(this, data.welcome_screen) : null; | ||
} | ||
} | ||
|
||
module.exports = InviteGuild; |
Oops, something went wrong.