#.setAuthor deprecation warning

1 messages ยท Page 1 of 1 (latest)

tacit elk
#

hey I had this problem earlier too xD

#
DeprecationWarning: Passing strings for the URL or the icon's URL for MessageEmbed#setAuthor is deprecated. Pass a sole object instead.
#

Passing strings for the URL is deprecated

pallid edge
#

ur welcome

tacit elk
#

I assume you already checked those 2 right?

timid dew
# tacit elk

This is what confuses me.

.setAuthor(`user.tag`, `user.avatarURL`)
Throws the exact same dep warning

tacit elk
#

yeah, because you are using strings

#

the error says that passing strings is deprecated

timid dew
#

But in the docs it literally says to use strings? lol

#

Type: string

tacit elk
pallid edge
timid dew
pallid edge
#

no im literally helping u, ur just not making an effort

#

so good luck

pearl hamlet
#

I was just about to send the solution

timid dew
timid dew
pallid edge
#

rule 6 do not ping me

timid dew
tacit elk
timid dew
tacit elk
#

so in .setAuthor you can have a string( which you would use if you only wanted text in the author field ) or you can use the EmbedAuthorData

timid dew
#

Yeah, so I'm still not understanding why
.setAuthor({ name: `${target?.user.tag}`, iconURL: `${target?.user.displayAvatarURL({ dynamic: true })}` })

Isn't viable

tacit elk
tacit elk
#
DeprecationWarning: Passing strings for the URL or the icon's URL for MessageEmbed#setAuthor is deprecated. Pass a sole object instead.
timid dew
#

Yeah so in other words use one of either name, url or iconURL?

tacit elk
#

no wait

#

look. You have

// `${target?.user.tag}`----> this variable is covered in a string
// `${target?.user.displayAvatarURL({ dynamic: true })}` -----> this is covered in a string
.setAuthor({ name: `${target?.user.tag}`, iconURL: `${target?.user.displayAvatarURL({ dynamic: true })}` })
#

you can do name: "Bob"

#

and it would work

tacit elk
timid dew
#

I tried that and still got the same warning though

tacit elk
#

passings strings for the URL or the icon's URL is deprecated

#

your iconURL is not a string, but you have it around the ``

timid dew
#

Hold up, let me find an older message from earlier today

#

So far I have tried, with no luck..

.setAuthor(`${message?.author?.tag}'s message was deleted`, `${message?.author?.displayAvatarURL({ dynamic: true })}`)
.setAuthor({ name: `${message?.author?.tag}'s message was deleted`, iconURL: `${message?.author?.displayAvatarURL({ dynamic: true })}` })
.setAuthor(message?.author?.tag message was deleted, message?.author?.displayAvatarURL({ dynamic: true }))

tacit elk
#

yeah, but he should learn how to read and understand errors

timid dew
#

I have tried all three of these

#

All gave me the dep warning

tacit elk
#

it says passing strings is deprecated

#

this is a string hello

#
`hello`
#

that is a string ^

#
iconURL: `${target?.user.displayAvatarURL({ dynamic: true })}`
#

that is also a string

timid dew
#

How about this?
.setAuthor(message?.author?.tag message was deleted, message?.author?.displayAvatarURL({ dynamic: true }))

tacit elk
#
.setAuthor({ name: `${target?.user.tag}`, iconURL: `${target?.user.displayAvatarURL({ dynamic: true })}` })

Use this one, but remove the strings

#

The error is telling you, you can't use strings in iconURL

timid dew
#

I see, I appreciate the help lol I won't lie, still confused as the docs sounds like it contradicting the dep warning. But I shall give that a try and see how I go ๐Ÿ˜„

tacit elk
#

btw why are you using the ``

#

It's not needed unless you are putting variables into a string

pearl hamlet
#

I used `` in mine and it worked fine

tacit elk
#

are you using the latest discord.js?

pearl hamlet
#

Yes

tacit elk
#

hm weird

pearl hamlet
#

That's not what his issue is

#

He can use backticks, it just needs to be an object which it is

tacit elk
#

this is what I have

.setAuthor({name: user.username, iconURL: user.displayAvatarURL({dynamic: true})})
timid dew
#

.setAuthor({ name: target?.user.tag, iconURL: target?.user.displayAvatarURL({ dynamic: true }) })

(Use `node --trace-deprecation ...` to show where the warning was created)```
pearl hamlet
#

You can do `${user.username}` and it will still work

#

send the full error @timid dew

timid dew
#

Oh

#

you mean trace

pearl hamlet
#

what command are you doing to trigger that?

timid dew
#
(node:20424) DeprecationWarning: Passing strings for the URL or the icon's URL for MessageEmbed#setAuthor is deprecated. Pass a sole object instead.
    at MessageEmbed.setAuthor (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\structures\MessageEmbed.js:381:17)
    at Object.execute (C:\Users\proba\Desktop\CreatorBot2.0\events\interaction\interactionCreate.js:32:18)
    at Client.<anonymous> (C:\Users\proba\Desktop\CreatorBot2.0\handlers\event_handler.js:22:54)
    at Client.emit (node:events:390:28)
    at InteractionCreateAction.handle (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\client\actions\InteractionCreate.js:73:12)
    at Object.module.exports [as INTERACTION_CREATE] (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\client\websocket\WebSocketManager.js:350:31)
    at WebSocketShard.onPacket (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\ws\lib\event-target.js:199:18)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\ws\lib\websocket.js:1098:20)
    at Receiver.emit (node:events:390:28)
    at Receiver.dataMessage (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\ws\lib\receiver.js:528:14)
    at Receiver.getData (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\ws\lib\receiver.js:446:17)
    at Receiver.startLoop (C:\Users\proba\Desktop\CreatorBot2.0\node_modules\ws\lib\receiver.js:148:22)
pearl hamlet
#

.setAuthor({ name: target?.user.tag})

#

try that on the whois command

#

and when you do the whois cmd let me know if it gives the same error

pearl hamlet
#

try {name: "Hello"}

#

if it still gives an error, its coming from somewhere else

pearl hamlet
#

are you using setAuthor anywhere else before you execute that command?

timid dew
#

I have no other embed in this file and I'm not requiring any other files and afaik no other code should be getting called at all https://sourceb.in/f0fzwXiZBo

pearl hamlet
#

Are you on the newest version of discord.js?

timid dew
#

Have been asking in djs server all day for help and no one could figure it out

pearl hamlet
#

your node is up to date too?

#

node -v

timid dew
#

Yessir

#

Well up to date enough, right? lol

pearl hamlet
#

Yea

#

The only thing i can think of is that setAuthor is getting called from somewhere else in your code and the error is being shown because it hasn't been updated

#

so for example if your bot sends logs, it may be using setAuthor

timid dew
#

Hmm, let me check

pearl hamlet
#

Use this in visual studio code, it should be up on the top left for you

#

then search for setAuthor

#

it will show you all of the files setAuthor is in

timid dew
#

Holy shit dude, you're a fucking genius ๐Ÿ˜„ I put a little log in interactionCreate while I was testing and never removed it ๐Ÿ˜„ duuude you're a god

pearl hamlet
#

sorted? pepesmile

timid dew
#

YES! Thank you my guy! I been racking my brain for hours trying to sort that out haha

pearl hamlet
#

ight no worries, have a good one

timid dew
#

Cheers mate, you too! Merry Christmas