首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >升级到v13时Discord.js v12代码中断

升级到v13时Discord.js v12代码中断
EN

Stack Overflow用户
提问于 2021-10-12 12:33:17
回答 1查看 497关注 0票数 0

在将我的discord.js更新到v13时,我收到许多错误:

代码语言:javascript
运行
复制
//member.hasPermission is not a function
member.hasPermission("SEND_MESSAGES")

//Cannot send an empty message
channel.send(someEmbed)

//Cannot send an empty message
channel.send({embed: someEmbed})

//Warning: The 'message' event was deprecated, use 'messageCreate' instead
client.on("message", msg => {})

//Cannot send an empty message
channel.send(user)

//[CLIENT_MISSING_INTENTS] Valid intents must be provided for the client
const client = new Client()

//channel.join is not a function
await channel.join()

这些在v12中不会发生,那么我如何在v13中修复它们呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-12 12:33:17

Discord.js v13有很多变化,但这些只是其中的一小部分。在更新到v13之前,您应该更改以下内容

代码语言:javascript
运行
复制
//member.hasPermission("SEND_MESSAGES")
member.permissions.has("SEND_MESSAGES")

//channel.send(someEmbed) / channel.send({embed: someEmbed})
channel.send({ embeds: [someEmbed] }) //make sure it's an array!

//client.on("message", msg => {})
client.on("messageCreate", msg => {})

//channel.send(user)
channel.send(user.toString())

//const client = new Client()
const { Intents, Client } = require("discord.js")
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}) //more intents may be provided

//await channel.join()
const { joinVoiceChannel } = require("@discordjs/voice") //requires installation
joinVoiceChannel({
  channelId: channel.id,
  guildId: guild.id,
  adapterCreator: guild.voiceAdapterCreator
})

还有更多的变化。您可以在guide中看到它们

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69540632

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档