From e5f3d96b16b004881521c667c7fd5912922bb209 Mon Sep 17 00:00:00 2001 From: yuko1101 <68993883+yuko1101@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:17:52 +0900 Subject: [PATCH] changed return type of ImageAssets#nextSource() to nullable --- CHANGELOG.md | 1 + src/models/assets/ImageAssets.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb69e8d..bb8bb54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 1.7.2 - Fixed image urls for AvatarRoundIcon. +- Changed return type of ImageAssets#nextSource() to nullable. # 1.7.1 - Fixed structure errors with new excels (v2.4+). - Improved code quality. diff --git a/src/models/assets/ImageAssets.ts b/src/models/assets/ImageAssets.ts index 7007073..79d8b40 100644 --- a/src/models/assets/ImageAssets.ts +++ b/src/models/assets/ImageAssets.ts @@ -29,7 +29,7 @@ export class ImageAssets { this.path = path; - this.imageBaseUrl = [...client.options.imageBaseUrls].filter(url => url.priority <= maxPriority).sort((a, b) => b.priority - a.priority).find(url => url.regexList.some(regex => regex.test(this.path))) ?? null; + this.imageBaseUrl = client.options.imageBaseUrls.filter(url => url.priority <= maxPriority).sort((a, b) => b.priority - a.priority).find(url => url.regexList.some(regex => regex.test(this.path))) ?? null; this.url = (() => { if (this.path === "" || this.imageBaseUrl == null) return ""; @@ -42,10 +42,10 @@ export class ImageAssets { } /** - * @returns a new instance of ImageAssets with the another imageBaseUrl, or this instance if the imageBaseUrl is null + * @returns a new instance of ImageAssets with the another imageBaseUrl */ - nextSource(): ImageAssets { - if (this.imageBaseUrl == null) return this; + nextSource(): ImageAssets | null { + if (this.imageBaseUrl == null) return null; return new ImageAssets(this.path, this.client, this.imageBaseUrl.priority - 1); } }