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?
#interaction.options.getUser only works with users inside your community
1 messages · Page 1 of 1 (latest)
If I understand you correctly you are trying to get a user by ID in a guild am I right?
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
so you are trying to get user info even if user is not in the guild?
So just getting the function to understand that it's valid is enough since everything it's trying to get from a user is either stored or not stored in my database for instance. It needs a user ID to do that search
Just their ID which is provided by the user running the command.
In this case, the bot throws any id that isn't in the same server as invalid
could you send me the code you have?
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
And on what line do you get your error here? Because getUser should work just fine with users not in your guild
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
Could you show me a screenshot of what you mean?
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?
Not sure and I have read about it
and yeah as you said code is not the issue as I have tried it and it works just fine
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 😄
Yeah. Good luck on your bot!
Thanks! 🙂
Where exactly do you copy from in mobile?
Do you maybe longtap the message and copy its id instead of tapping the user and then copying id from the … menu?
No I'm doing it on the user
Send a screenshot of where you do it please
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
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()