简体   繁体   English

如何在 discord.js 中使用特定的公会 ID?

[英]How can I use a specific guild ID in discord.js?

I currently am working in a script that's automatically updated, and not called by any command or message.我目前正在使用一个自动更新的脚本,而不是由任何命令或消息调用。 Thus, I have no message variable to call message.guild.id with.因此,我没有可以调用 message.guild.id 的消息变量。 I am making a bot for one specific server, and I need my code to edit a specific channel within that server, thus needing the server ID.我正在为一个特定的服务器制作一个机器人,我需要我的代码来编辑该服务器中的特定频道,因此需要服务器 ID。 I tried我试过了

let server = client.guilds.get('<guild id>'), channel;

and using the server variable to find the specific channel I want it to edit.并使用服务器变量来查找我希望它编辑的特定频道。 This however gives an error.然而,这给出了一个错误。 Am I missing any dependencies, or is there an easier way to do this?我是否缺少任何依赖项,还是有更简单的方法来做到这一点?

Thanks in advance!提前致谢!

client.guilds.get does not exist anymore. client.guilds.get不再存在。 Use client.guilds.cache.get使用client.guilds.cache.get

let server = client.guilds.cache.get('<guild id>')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM