TypeError:message.guild.channels.find不是函数discord.js

以下代码在标题中产生错误:

message.guild.channels.create("ticket-" + data.ticketCounter, 
{
  type: 'text',
  parent: '702634860363382784',
  permissionOverwrites: [
    {
      id: message.guild.id,
      deny: ['VIEW_CHANNEL']
    },
    {
      id: message.author.id,
      allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'ADD_REACTIONS', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY', 'USE_EXTERNAL_EMOJIS']
    },
    {
      id: "702701257290154044",
      allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'ADD_REACTIONS', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY', 'USE_EXTERNAL_EMOJIS']
    }
  ]
})

const ticketEmbed = new Discord.MessageEmbed()
  .setColor(config.embedColor)
  .setTitle('New ticket from ' + message.author.tag)
  .setDescription(messageContent.join(" "))

const ticketChannel = message.guild.channels.find('name', `ticket-${data.ticketChannel}`);
ticketChannel.send(ticketEmbed)

I've already seen this post: TypeError: message.guild.channels.find(...).then is not a function and am using the code in there, but I'm still getting the error. I'm on Discord.js version 12.2.0, node.js version 12.16.1, and npm version 6.14.4

评论
  • 间接性抑郁
    间接性抑郁 回复

    It's been updated I believe. Try using: message.guild.channels.cache.find Hope this helps!