相关疑难解决方法(0)

如何将我的代码从 v11 迁移到 Discord.js v12?

我升级到 Discord.js v12,但它破坏了我现有的 v11 代码。以下是导致错误的一些示例:

// TypeError: client.users.get is not a function
const user = client.users.get('123456789012345678')

// TypeError: message.guild.roles.find is not a function
const role = message.guild.roles.find(r => r.name === 'Admin')

// TypeError: message.member.addRole is not a function
await message.member.addRole(role)

// TypeError: message.guild.createChannel is not a function
await message.guild.createChannel('welcome')

// TypeError: message.channel.fetchMessages is not a function
const messages = await message.channel.fetchMessages()

const {RichEmbed} = require('discord.js')
// TypeError: RichEmbed is not a constructor
const embed = new RichEmbed()

const connection = …
Run Code Online (Sandbox Code Playgroud)

javascript discord discord.js

5
推荐指数
1
解决办法
1628
查看次数

标签 统计

discord ×1

discord.js ×1

javascript ×1