[英]Is there any way I can make it so I don't have to redeclare dependencies for module.exports?
I am working on a discord bot.我正在开发一个不和谐的机器人。 I'm kinda a new at this, so I followed discordjs.guide for this bot.
我对这个有点陌生,所以我关注了这个机器人的 discordjs.guide。 I was wondering if there was a way I could use module.exports, while not having to constantly redeclare dependencies such as
const Discord = require('discord.js')
or function that I have in app.js.我想知道是否有一种方法可以使用 module.exports,而不必经常重新声明依赖项,例如
const Discord = require('discord.js')
或 app.js 中的函数。
Repo here: https://github.com/boomermath/grapeoverhaul .此处回购: https : //github.com/boomermath/grapeoverhaul 。
In your app.js
file, whatever parameters you pass into execute()
will passover to the command file.在您的
app.js
文件中,您传递给execute()
任何参数都将传递给命令文件。 So just add Discord
into the parameters.所以只需将
Discord
添加到参数中即可。
command.execute(Discord, message, args);
Make sure the order of parameters is the exact same across all files, otherwise this will cause an error确保所有文件的参数顺序完全相同,否则会导致错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.