Shane
Shane
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
1.178s → 0.457s
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
I swapped it out with this
{
// Fetch references from pins
let references = await Promise.all(pins.map(p => p.reference && (
message.channel.messages.cache.get(p.reference.messageId) ||
message.channel.messages.fetch(p.reference.messageId)
)))
// Insert references before the relevant pin (working backwards to prevent indexes moving)
for (let i = pins.length - 1; i >= 0; i--)
if(references[i]) pins.splice(i, 0, references[i])
}
{
// Fetch references from pins
let references = await Promise.all(pins.map(p => p.reference && (
message.channel.messages.cache.get(p.reference.messageId) ||
message.channel.messages.fetch(p.reference.messageId)
)))
// Insert references before the relevant pin (working backwards to prevent indexes moving)
for (let i = pins.length - 1; i >= 0; i--)
if(references[i]) pins.splice(i, 0, references[i])
}
And I seem to get what I'm looking for, so thank you I thought this was redundancy, but it does seem to cut the eval time in half (with only 3 pins in total, one of which doesn't have a reference to begin with)
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
For some reason I assumed that cache was always checked first, and then it falls back to making an API request I'll give this one a try
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
Still says that it accepts an array of MessageResolvable
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
That does happen to have identical content to the cached page I've got, though I've been redirected now to the old subdomain
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
Oh I see
14 replies
DIAdiscord.js - Imagine an app
Created by Shane on 7/1/2023 in #djs-questions
Fetch an array of message IDs at once
# npm list; node -v
beta@ /home/shane/Documents/Discord Bot/beta

v20.3.1
# npm list; node -v
beta@ /home/shane/Documents/Discord Bot/beta

v20.3.1
14 replies