![](/img/trans.png)
[英]I cannot access the variable in the other script. (Module.exports don't work everywhere)
[英]Is there any way I can make it so I don't have to redeclare dependencies for module.exports?
我正在开发一个不和谐的机器人。 我对这个有点陌生,所以我关注了这个机器人的 discordjs.guide。 我想知道是否有一种方法可以使用 module.exports,而不必经常重新声明依赖项,例如const Discord = require('discord.js')
或 app.js 中的函数。
此处回购: https : //github.com/boomermath/grapeoverhaul 。
在您的app.js
文件中,您传递给execute()
任何参数都将传递给命令文件。 所以只需将Discord
添加到参数中即可。
command.execute(Discord, message, args);
确保所有文件的参数顺序完全相同,否则会导致错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.