#DisplayAvatarURL taking too much time to exec

1 messages · Page 1 of 1 (latest)

brittle smelt
#

I mean that if you put a console.log just above this code, it should be peintes instantly as you send the command

shut garnet
#

yes

#

these are my intents

#
const client = new Discord.Client({ intents, partials: ['CHANNEL', 'MESSAGE', 'GUILD_MEMBER', 'REACTION'] })```
#

just

#

all

#

intents

#

and

#
const { MessageEmbed } = require('discord.js')

module.exports = {
    name: 'avatar',
    aliases: ['av', 'ab', 'ac', 'ah', 'pfp', 'avi', 'ico', 'icon'],
    permissions: [],
    description: 'displays a users avatar',
    usage: `- $avatar <mention>\n- $avatar <username>\n- $avatar <tag/id>`,
    async execute(client, message, cmd, args, Discord) {

        const noEmote = '![arseniccross](https://cdn.discordapp.com/emojis/934071290694869072.webp?size=128 "arseniccross")';
        const yesEmote = '![arseniccheck](https://cdn.discordapp.com/emojis/934071296789205033.webp?size=128 "arseniccheck")';
        const warnEmote = '![arsenicwarning](https://cdn.discordapp.com/emojis/934071306092167218.webp?size=128 "arsenicwarning")';

        let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(m => m.displayName.toLowerCase() === args.join(' ')?.toLocaleLowerCase()) || message.guild.members.cache.find(m => m.user.username.toLowerCase() === args.join(' ')?.toLocaleLowerCase() || message.guild.members.cache.find(m => m.user.tag.toLowerCase() === args.join(' ')?.toLocaleLowerCase())) || message.guild.members.cache.find(m => m.user.username.toLowerCase().includes(args.join(' '))) || message.member
        let author = message.author

        if (!args[0]) {

            let e = new MessageEmbed()
                .setDescription(`[*${author.username}'s avatar*](${author.displayAvatarURL()})`)
                .setURL(author.displayAvatarURL())
                .setImage(author.displayAvatarURL({ dynamic: true, size: 4096 }))
                .setFooter({ text: `Requested by ${author.tag}` })
                .setColor(`#303135`)

            await message.reply({ embeds: [e] })

        } else {

            let e = new MessageEmbed()
                .setDescription(`[*${member.user.username}'s avatar*](${member.user.displayAvatarURL()})`)
                .setImage(member.user.displayAvatarURL({ dynamic: true, size: 4096 }))
                .setFooter({ text: `Requested by ${author.tag}` })
                .setColor(`#303135`)

            await message.reply({ embeds: [e] })

        }

    }
}```
#

this is my entire av cmd

#

only message.author.displayAvatarURL is taking too long to execute

#

member.user.displayAvatarURL

#

works

#

just

#

fine

#

im so confused

#

@brittle smelt

brittle smelt
#

The dynamic arg is for gif pp i guess ?

shut garnet
#

yes

brittle smelt
#

Hm

#

How much members on the big guild ?

shut garnet
#

2412

brittle smelt
#

Hmmm

#

And if you do the command two times ?

#

Is the second time faster ?

shut garnet
#

nope

brittle smelt
#

Si not a cache problem..

#

Do you debugged the code ?

#

Like, putting console.logs everywhere to see what exact line it comes from ?

#

You should do it

shut garnet
#

what would i be logging tho

#

theres no errors

#

its almost as if its an api issue

brittle smelt
#

I don’t think so

shut garnet
#

i thought maybe message.member instead of message.author would be faster because its a user object but nope

brittle smelt
#

And jut print "check 1", "check 2" at différents places and see where is the time execution exceeding

shut garnet
#

still the same