Discord 如何使我的bot在出现提示时向指定的角色id授予发送消息权限"=“roleid抢劫案”;
我制作了一个discord bot,并制作了一个函数,在该函数中,它为成员角色解锁通道,该角色被指定给我服务器中的每个人。我想这样做,它需要在写入id后解锁的id,因此基本上Discord 如何使我的bot在出现提示时向指定的角色id授予发送消息权限"=“roleid抢劫案”;,discord,discord.js,Discord,Discord.js,我制作了一个discord bot,并制作了一个函数,在该函数中,它为成员角色解锁通道,该角色被指定给我服务器中的每个人。我想这样做,它需要在写入id后解锁的id,因此基本上=heist roleid。 我希望此操作仅为给定角色解锁频道 我当前的代码: const Discord = require("discord.js"); const client = new Discord.Client(); const prefix = ('=') var nume
=heist roleid
。
我希望此操作仅为给定角色解锁频道
我当前的代码:
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = ('=')
var numeral = require('numeral');
client.once('ready', () => {
console.log('Dank heists is now online');
client.user.setPresence({
activity: {
type:"PLAYING",
name: "discord.io/heists",
status: "available",
}
});
});
else if (message.content.startsWith(prefix +'heist' )) {
message.channel.createOverwrite("793930139737128997", {
SEND_MESSAGES: true
})
.then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
.catch(console.error);
const embed = new Discord.MessageEmbed()
.setTitle('HEIST HAS NOW STARTED!!!')
.setThumbnail('https://img2.pngio.com/unlocked-padlock-png-transparent-unlocked-padlockpng-images-lock-unlock-png-512_512.png')
.setColor('#1d35cf')
.setFooter('Manan, ')
.setDescription(" I HAVE UNLOCKED THIS CHANNEL SO PEOPLE CAN JOIN THE HEIST " )
message.channel.send(embed)
}
如果可能,请一起更新并发送整个代码我建议您先学习JavaScript,然后学习Discord.js和Node.js的基础知识 回答你的问题:
else if(message.content.startsWith(前缀+“heist”)){
const roleT=message.content.replace(前缀+“heist”,”).trim();
const role=message.guild.roles.cache
.filter((r)=>r.name.toLowerCase()==roleT.toLowerCase())
.first();
如果(!角色){
返回message.channel.send(“请标记角色!”);
}
消息通道
.createOverwrite(role.id{
发送消息:正确,
})
。然后((频道)=>
console.log(channel.permissionOverwrites.get(message.author.id))
)
.catch(控制台错误);
const embed=new Discord.MessageEmbed()
.setTitle(“抢劫现在已经开始!!!”)
.setThumbnail(
"https://img2.pngio.com/unlocked-padlock-png-transparent-unlocked-padlockpng-images-lock-unlock-png-512_512.png"
)
.setColor(“1d35cf”)
.setFooter(“Manan,”)
.setDescription(
“我已解锁此频道,以便人们可以加入抢劫”
);
message.channel.send(嵌入);
}
谢谢您的帮助。我把它换了,现在它可以工作了!