Skip to content

Commit

Permalink
add nofallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Oct 28, 2024
1 parent 1d27694 commit 2f50d98
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@ class Member {
);
}

/**
* The url of the member's avatar without falling back to the user's avatar.
* @readonly
* @type {String}
* @public
*/
get displayAvatarURLNoFallback() {
return Member.getAvatarUrl(
this.id,
this.guildId,
this.#_originalAvatarHash,
);
}

/**
* Whether the user has not yet passed the guild's membership screening requirements.
* @readonly
Expand Down
22 changes: 22 additions & 0 deletions test/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("Member", function () {
expect(member).to.have.property("highestRolePosition");
expect(member).to.have.property("rejoined");
expect(member).to.have.property("displayAvatarURL");
expect(member).to.have.property("displayAvatarURLNoFallback");
expect(member).to.have.property("permissions");
expect(member).to.have.property("avatarIsAnimated");
expect(member).to.have.property("mention");
Expand Down Expand Up @@ -639,6 +640,15 @@ describe("Member", function () {
});
});

context("check displayAvatarURLNoFallback", function () {
it("should have the correct displayAvatarURLNoFallback", function () {
const client = TEST_CLIENTS.ALL_CACHES_ENABLED();
TEST_GUILDS.ALL_CACHES_ENABLED(client);
const member = TEST_MEMBERS.GENERIC_MEMBER(client);
expect(member.displayAvatarURLNoFallback).to.be.null;
});
});

context("check permissions", function () {
it("should have the correct permissions", function () {
const client = TEST_CLIENTS.ALL_CACHES_ENABLED();
Expand Down Expand Up @@ -831,6 +841,9 @@ describe("Member", function () {
expect(rebundled.rejoined).to.equal(member.rejoined);
expect(rebundled.permissions).to.equal(member.permissions);
expect(rebundled.displayAvatarURL).to.equal(member.displayAvatarURL);
expect(rebundled.displayAvatarURLNoFallback).to.equal(
member.displayAvatarURLNoFallback,
);
expect(rebundled.pending).to.equal(member.pending);
expect(rebundled.avatarIsAnimated).to.equal(member.avatarIsAnimated);
expect(rebundled.mention).to.equal(member.mention);
Expand Down Expand Up @@ -862,6 +875,9 @@ describe("Member", function () {
expect(rebundled.rejoined).to.equal(member.rejoined);
expect(rebundled.permissions).to.equal(member.permissions);
expect(rebundled.displayAvatarURL).to.equal(member.displayAvatarURL);
expect(rebundled.displayAvatarURLNoFallback).to.equal(
member.displayAvatarURLNoFallback,
);
expect(rebundled.pending).to.equal(member.pending);
expect(rebundled.avatarIsAnimated).to.equal(member.avatarIsAnimated);
expect(rebundled.mention).to.equal(member.mention);
Expand Down Expand Up @@ -893,6 +909,9 @@ describe("Member", function () {
expect(rebundled.rejoined).to.equal(member.rejoined);
expect(rebundled.permissions).to.equal(member.permissions);
expect(rebundled.displayAvatarURL).to.equal(member.displayAvatarURL);
expect(rebundled.displayAvatarURLNoFallback).to.equal(
member.displayAvatarURLNoFallback,
);
expect(rebundled.pending).to.equal(member.pending);
expect(rebundled.avatarIsAnimated).to.equal(member.avatarIsAnimated);
expect(rebundled.mention).to.equal(member.mention);
Expand Down Expand Up @@ -924,6 +943,9 @@ describe("Member", function () {
expect(rebundled.rejoined).to.equal(member.rejoined);
expect(rebundled.permissions).to.equal(member.permissions);
expect(rebundled.displayAvatarURL).to.equal(member.displayAvatarURL);
expect(rebundled.displayAvatarURLNoFallback).to.equal(
member.displayAvatarURLNoFallback,
);
expect(rebundled.pending).to.equal(member.pending);
expect(rebundled.avatarIsAnimated).to.equal(member.avatarIsAnimated);
expect(rebundled.mention).to.equal(member.mention);
Expand Down

0 comments on commit 2f50d98

Please sign in to comment.