use find instead of filter
This commit is contained in:
parent
fd706d7d29
commit
b85b65dda0
1 changed files with 2 additions and 2 deletions
4
main.mjs
4
main.mjs
|
@ -57,8 +57,8 @@ function getMessageUrl(msg) {
|
|||
}
|
||||
|
||||
function getTextLink(msg) {
|
||||
const textLinks = (msg.entities ?? []).filter(isTextLink);
|
||||
return textLinks.length ? textLinks[0].url : null;
|
||||
const textLink = (msg.entities ?? []).find(isTextLink);
|
||||
return textLink ? textLink.url : null;
|
||||
}
|
||||
|
||||
function isTextLink(msgEntity) {
|
||||
|
|
Reference in a new issue