Can I get only id from value?

Here's my code
module.exports = {
developer: true,

data: new SlashCommandBuilder()
.setName("point")
.setDescription("point command")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption((option) =>
option
.setName('user')
.setDescription('input user')
.setRequired(true))

.addStringOption((option) =>
option.setName("point")
.setDescription("input point")
.setRequired(true)),

execute(interaction, client){
if(interaction.isChatInputCommand()){
const user = interaction.options.get('user').value
const point = interaction.options.get('point').value

interaction.reply({content: "sent " + point + " to " + user});
}
}
}
module.exports = {
developer: true,

data: new SlashCommandBuilder()
.setName("point")
.setDescription("point command")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption((option) =>
option
.setName('user')
.setDescription('input user')
.setRequired(true))

.addStringOption((option) =>
option.setName("point")
.setDescription("input point")
.setRequired(true)),

execute(interaction, client){
if(interaction.isChatInputCommand()){
const user = interaction.options.get('user').value
const point = interaction.options.get('point').value

interaction.reply({content: "sent " + point + " to " + user});
}
}
}
And in user value it return like <@1063730517876408381> this But I Just want to user id 1063730517876408381 So I tried to using replace But not work.. D:\Project\minecraft\Commission\Illusion\Bot\Illusion\commands\Developer\point.js:34 user = user.replace("@" ,"") ^ TypeError: Assignment to constant variable. How Can I get only id from that value?
11 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
edocsil
edocsil2y ago
interaction.options.getUser('user').id
계정 버림
계정 버림OP2y ago
I tried it but return undefined
edocsil
edocsil2y ago
.addUserOption instead of .addStringOption Unless you have a specific reason for letting people put whatever stuff they want in the option and have to deal with parsing it
계정 버림
계정 버림OP2y ago
Still return undefined
edocsil
edocsil2y ago
Post your updated code
계정 버림
계정 버림OP2y ago
module.exports = {
developer: true,

data: new SlashCommandBuilder()
.setName("point")
.setDescription("point command")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addUserOption((option) =>
option
.setName('user')
.setDescription('input user')
.setRequired(true))

.addStringOption((option) =>
option.setName("point")
.setDescription("input point")
.setRequired(true)),

execute(interaction, client){
if(interaction.isChatInputCommand()){
const user = interaction.options.get('user').id
const point = interaction.options.get('point').value

interaction.reply({content: "sent " + point + " to " + user});
}
}
}
module.exports = {
developer: true,

data: new SlashCommandBuilder()
.setName("point")
.setDescription("point command")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addUserOption((option) =>
option
.setName('user')
.setDescription('input user')
.setRequired(true))

.addStringOption((option) =>
option.setName("point")
.setDescription("input point")
.setRequired(true)),

execute(interaction, client){
if(interaction.isChatInputCommand()){
const user = interaction.options.get('user').id
const point = interaction.options.get('point').value

interaction.reply({content: "sent " + point + " to " + user});
}
}
}
Edit like this
edocsil
edocsil2y ago
^
계정 버림
계정 버림OP2y ago
ops I am just stupid wait a sec
edocsil
edocsil2y ago
Or .get("user").value.id
계정 버림
계정 버림OP2y ago
Thank uuu getUser this was the prob haha
Want results from more Discord servers?
Add your server