【发布时间】:2021-09-08 17:53:19
【问题描述】:
我的应用系统完成了 90%,但我缺少一件事
我正在尝试在有人申请时添加角色, 我试着用这个来做
let teamRole = message.guild.roles.cache.find(role => role.id == "761996603434598460")
member.roles.add(teamRole)
但它没有添加角色(我没有得到任何错误)
我有什么方法可以使用下面的代码进行交互吗?
client.ws.on("INTERACTION_CREATE", async (interaction) => {
// If component type is a button
if (interaction.data.component_type === 2) {
const guildId = interaction.guild_id;
const userId = interaction.member.user.id;
const buttonId = interaction.data.custom_id;
const member = client.guilds.resolve(guildId).member(userId);
if (buttonId == "send_application") {
// Reply to an interaction, so we don't get "This interaction failed" error
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: "I have started the application process in your DM's.",
flags: 64 // make the message ephemeral
}
}
});
感谢您的帮助
【问题讨论】:
标签: discord discord.js discord-buttons