Index.js:
const client = new Discord.Client();
require(`./commands/myCommand.js`);
命令/ myCommand.js:
[some code that uses the client const]
如何从命令文件中访问client
const
?
答案 0 :(得分:0)
最简单的方法可能是从message.client
获取客户端对象。
您还可以在调用index.js中的命令execute
函数时将客户端对象作为参数传递
command.execute(client, message, args)