mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 04:12:50 +02:00
Add full coverage for previous commit
This commit is contained in:
parent
8d452102d5
commit
9158eb2476
3 changed files with 47 additions and 1 deletions
|
@ -268,6 +268,7 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
* @param {string} content Partial or complete Discord message content
|
||||
*/
|
||||
async function transformContentMessageLinks(content) {
|
||||
let offset = 0
|
||||
for (const match of [...content.matchAll(/https:\/\/(?:ptb\.|canary\.|www\.)?discord(?:app)?\.com\/channels\/([0-9]+)\/([0-9]+)\/([0-9]+)/g)]) {
|
||||
assert(typeof match.index === "number")
|
||||
const channelID = match[2]
|
||||
|
@ -286,7 +287,8 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
} else {
|
||||
result = `${match[0]} [event is from another server]`
|
||||
}
|
||||
content = content.slice(0, match.index) + result + content.slice(match.index + match[0].length)
|
||||
content = content.slice(0, match.index + offset) + result + content.slice(match.index + match[0].length + offset)
|
||||
offset += result.length - match[0].length
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue