好吧,所以我有一些创建角色的基本代码,并且找到了角色,我尝试从保存或找到它的const中获取const的ID,但是在100%的时间中它为空,因此创建了角色并IDK问题。
const roleowo = msg.guild.createRole({ name: channelname, color: 'YELLOW' }).then((role) => {msg.member.addRole(role);}).catch(console.error);
let myRole = msg.guild.roles.get(roleowo);
msg.guild.createChannel(channelname, {
type: 'voice',
permissionOverwrites: [
{
id: 'this is an actual id but I will not show it here I am dumb',
deny: ['VIEW_CHANNEL'],
},
{
id: myRole.id,
allow: ['VIEW_CHANNEL'],
}
]
});
答案 0 :(得分:2)
roleowo
等于Promise<Role>
。您需要将所有代码放入.then()
msg.guild.createRole({ name: channelname, color: 'YELLOW' })
.then((role) => {
msg.member.addRole(role);
msg.guild.createChannel(channelname, {
type: 'voice',
permissionOverwrites: [
{
id: 'this is an actual id but I will not show it here I am dumb',
deny: ['VIEW_CHANNEL'],
},
{
id: role.id,
allow: ['VIEW_CHANNEL'],
}
]
});
})
.catch(console.error);