[英]message.client.guilds.fetch() is not a function
Here's the relevant snippet of the code I was working on:这是我正在处理的代码的相关片段:
message.client.guilds.fetch('ID Here', false).then(guild => message.channel.send(guild.name))
According do thediscord.js
docs , this function, GuildManager#fetch()
, should theoretically work.据做
discord.js
文档,这个功能, GuildManager#fetch()
理论上应该工作。 However, I keep getting this error:但是,我不断收到此错误:
message.client.guilds.fetch is not a function
I even tried directly copying and pasting the example from the function docs, but it still gave me the same error.我什至尝试直接从函数文档中复制和粘贴示例,但它仍然给了我同样的错误。
I'm fairly stumped, any help would be appreciated!我很难过,任何帮助将不胜感激!
Edit: I should mention that all other discord.js
fetch
methods are working fine, such as:编辑:我应该提到所有其他
discord.js
fetch
方法都可以正常工作,例如:
message.channel.messages.fetch()
Edit #2: My previous problem has been solved, I was using the wrong version of discord.js
.编辑#2:我之前的问题已经解决,我使用了错误版本的
discord.js
。 However, I now get a new error:但是,我现在收到一个新错误:
DiscordAPIError: Missing Access
When running it.运行时。
You are most likely using an outdated discord.js
version.您很可能使用过时的
discord.js
版本。 client.guilds
was made a GuildManager
as of v12.0.0 and the method client.guilds.fetch
was added only in the latest version v12.3.0. client.guilds
被做了GuildManager
为v12.0.0和方法client.guilds.fetch
只在最新版本v12.3.0加入。 You need to have a discord.js
version >= 12.3.0 in order to use this method.你需要有一个
discord.js
为了使用这种方法的版本> = 12.3.0。
Try npm ls discord.js
to check the active version in your dependencies.尝试使用
npm ls discord.js
检查依赖项中的活动版本。
Try npm i discord.js@latest
to forcefully upgrade to latest version.尝试
npm i discord.js@latest
强制升级到最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.