【发布时间】:2020-07-26 13:58:18
【问题描述】:
我正在尝试使用 discord.js 创建一个不和谐机器人。
基本上,我想创建一个类别并获取 id,然后创建另一个以该类别为父的频道,但我无法获得 id。
使用console.log(tempo1.id) 我得到undefined。
如果有人认为我是一个接受者,我整天都在寻找和尝试,但没有任何结论。
提前感谢您的帮助 =))
代码:
bot.on('message', message => {
if (message.content === ${prefix}vocal) {
const tempo1 = guild.channels.create('Channel Tempo', {
type: 'category'
}).then(console.log)
//guild.channels.create('Text Channel Tempo', { type: 'text' })
console.log(`Hello from ${tempo1}!`)
console.log(tempo1.id)
} })
控制台输出
Ready!
Hello from [object Promise]!
undefined
CategoryChannel {
type: 'category',
deleted: false,
id: '699377593845022741',
name: 'Channel Tempo',
rawPosition: 9,
parentID: null,
permissionOverwrites: Collection [Map] {},
guild: Guild {
members: GuildMemberManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
channels: GuildChannelManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
roles: RoleManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
presences: PresenceManager {
cacheType: [Function: Collection],
cache: [Collection [Map]]
},
voiceStates: VoiceStateManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
}
}
}
【问题讨论】:
标签: javascript