#interaction.options.getUser only works with users inside your community

1 messages · Page 1 of 1 (latest)

soft solstice
#

I'm having an issue with a command I'm working on. To get a mentioned user I'm currently using "interaction.options.getUser" which has been working perfectly fine recently, until I've realised you can't input user id's of people who arent in that same discord server without it returning as invalid id. Is there any way to solve this or otherwise any other methods I should use?

somber solstice
soft solstice
#

Yes but I want the bot to be able to also recognise ID's as valid even if they aren't in the same guild

#

By ID

#

The bot isn't fetching user information

#

It's checking for data stored in a database by ID

somber solstice
#

so you are trying to get user info even if user is not in the guild?

soft solstice
soft solstice
#

In this case, the bot throws any id that isn't in the same server as invalid

somber solstice
#

could you send me the code you have?

soft solstice
#
data: new SlashCommandBuilder()
    .setName('checkuser')
    .setDescription('Check user database status')
    .addUserOption(option =>
        option.setName('target')
            .setDescription('Insert Discord ID or Ping Someone')
            .setRequired(true)),
async execute(interaction) {
    let userID = interaction.options.getUser('target').id;
    let userInfo = await func.getUserFromDB(userID);
    if (!userInfo) {
        //not in database
    } else {
        //in database
    }
},
#

"func" is just a separate js file with some custom mysql functions

mortal arrow
soft solstice
#

No errors in the code. I only get the alert in discord

If I mention or input the ID of someone in the same guild it runs fine
If I input the ID of someone not in the guild it gives me a warning that it's an invalid ID

mortal arrow
#

Could you show me a screenshot of what you mean?

soft solstice
#

Give me just a sec

#

As I just ran it, I realise that this isn't a bot issue. I ran it on PC it works fine but not on mobile since they copy two different ID's
PC: 275823164578070529
Mobile: 720630434089926697

#

What ID is mobile referencing?

somber solstice
#

and yeah as you said code is not the issue as I have tried it and it works just fine

soft solstice
#

Yeah... well if it's working fine, it's working fine. It just a questing of mobile copying some other ID

#

I appreciate everyone's insight and help 😄

somber solstice
soft solstice
#

Thanks! 🙂

mortal arrow
#

Do you maybe longtap the message and copy its id instead of tapping the user and then copying id from the … menu?

soft solstice
#

No I'm doing it on the user

mortal arrow
soft solstice
mortal arrow
# soft solstice

That’s the id of the dmChannel you have with them, not the user

#

Tap the user anywhere in the channel (to see their profile) and tap the … in the top corner there->copy ID

soft solstice
#

You're right! That works hahaha 😄

#

I appreciate it loads

soft solstice
#

Can I create a resolvable user object for a user who is not a guildmember?

It is a button interaction so I can't use interaction.options.getUser()