我正在用message.guild.channels.create创建一个频道。然后如何查找该通道的消息id并在新创建的通道中发送消息?
message.guild.channels.create(`bug-priority${reportPriority}-${reportStart}`, {
type: 'text',
permissionOverwrites: [{
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
},
{
id: memberRole.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
}]
})发布于 2021-02-22 17:23:33
guild.channels.create返回一个解析为GuildChannel的承诺。这意味着您可以等待结果,这是新创建的通道:
const channel = await message.guild.channels.create(`bug-priority${reportPriority}-${reportStart}`, {
type: 'text',
permissionOverwrites: [
{
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
},
{
id: memberRole.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
},
],
});
const { id } = channel;确保父函数是async函数。
发布于 2021-02-22 17:27:32
您可以在创建通道后使用bot.channels.cache.find()获取id,如下所示:
let channel = bot.channels.cache.find(channel => channel.name === "name here");
let channelid = channel.id;希望这能帮上忙!
https://stackoverflow.com/questions/66320371
复制相似问题