admin管理员组文章数量:1429841
Ive been trying to figure out how to get my hug mand to mention both the sender and the recipient of the mand. As well as when you start the mand it'll ask for the sender to select someone to mention before the mand is sent off (or is that built in? I don't know yet)
I have read over the docs of the user class and as well as read this post here but have e to the conclusion that both aren't using slash mands though which is what ive been taught of how to do, not using embeds or text for the mands, just a slash mand. If there is any help to this that would be greatly appreciated! Here's my resulting code so far though
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('hug')
.setDescription('Hug Someone'),
async execute(interaction) {
return interaction.reply(`${user} hugs ${user}`)
},
};
Ive been trying to figure out how to get my hug mand to mention both the sender and the recipient of the mand. As well as when you start the mand it'll ask for the sender to select someone to mention before the mand is sent off (or is that built in? I don't know yet)
I have read over the docs of the user class and as well as read this post here but have e to the conclusion that both aren't using slash mands though which is what ive been taught of how to do, not using embeds or text for the mands, just a slash mand. If there is any help to this that would be greatly appreciated! Here's my resulting code so far though
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('hug')
.setDescription('Hug Someone'),
async execute(interaction) {
return interaction.reply(`${user} hugs ${user}`)
},
};
Share
Improve this question
asked Feb 9, 2022 at 12:46
CalebOWolfCalebOWolf
132 silver badges7 bronze badges
1 Answer
Reset to default 3You can get the author of the Interaction
using the Interaction#user
property.
To specify a User
to hug you'll have to add a SlashCommandUserOption
.
You can then get the User
by using CommandInteractionOptionResolver#getUser
module.exports = {
data: new SlashCommandBuilder()
.setName('hug')
.setDescription('Hug Someone')
.addUserOption(option =>
option
.setName('user')
.setDescription('The user you want to hug')
.setRequired(true)
),
async execute(interaction) {
return interaction.reply(`${interaction.user} hugs ${interaction.options.getUser('user')}`)
},
};
本文标签: javascriptDiscordjs Slash command mention userStack Overflow
版权声明:本文标题:javascript - Discord.js Slash command mention user - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745555282a2663148.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论