#Missing Member in messages

1 messages · Page 1 of 1 (latest)

radiant root
#

no, sorry fetchmessages

grim geyser
#

can you show the code?

#

it shouldnt be undefined, it should be null if it doesnt exist

#

are you resolving the promise?

radiant root
#

resolving the promise @grim geyser?

grim geyser
#

yes, fetching returns a promise, you are probably getting partial data if you are not resolving the promise

radiant root
#

understood

#

do I await it instead?

grim geyser
#

await will work yes

radiant root
#
let targets = await messages.filter(m => m.author.id != client.user.id);```
#

Like so in an await function?

#

Like that, but in an await function

grim geyser
#

you need to await when you fetch, not filter
and yeah it needs to be in async function (unless you are using esm with top level await)

radiant root
#

gotcha

radiant root
#
setInterval(async () => {
    let messages = await client.guilds.get('185590609631903755').channels.get('872955650982948904').fetchMessages({limit: 100});
    let targets = messages.filter(m => m.author.id != client.user.id);

    targets.forEach(async m => {

        if (m.member) {
            console.log('Member: ' + m.member.displayName);
            
        } else {
            console.log('N o  Member');

        }

        if (m.member.roles.has(client.blender.memberRole)) return m.delete();
        if (m.content.toLowerCase().includes(client.blender.password.toLowerCase())) {
            m.member.addRole(client.blender.memberRole);
            m.delete();
        }
    });




}, 5000);```
grim geyser
#

fetchMessages isnt v13, i cant provide help with older versions as im not familiar with them and/or any shortcomings they might have

radiant root
#

heck

#

Im trying to fix with small problem before I do my full V13 upgrade

grim geyser
#

in v13, its await <TextChannel>.messages.fetch({ limit: 100 })