【发布时间】:2020-10-10 01:48:11
【问题描述】:
所以我的意思是我想在函数中导出某个对象。
async function Set(x) {
module.exports["x"] = x
}
这似乎不起作用,并且它变得未定义,你们能帮忙吗?
client.on('message', async message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
var args = message.content.split(/[ ]+/)
const Cargs = message.content.slice(prefix.length).trim().split(/[ ]+/);
const command = Cargs.shift().toUpperCase();
if (client.commands.get(command)) {
await Set(message)
client.commands.get(command).execute()
}
})
【问题讨论】:
-
您希望在什么背景下执行此操作? IE。你在哪里调用这个函数
Set? -
我想这样做是因为我有另一个函数需要反复更改导出。
-
您能否发布一个调用此代码的代码示例?
-
我刚刚编辑了我的代码,最后一行的 4 是我调用 Set 的地方。
-
目前还不清楚您要在这里做什么。好的,我可以看到您正在调用
Set函数,但是您希望导入在哪里发生变化?