我正在尝试将我的 Discord 机器人的活动设置为“游戏”,但是我在网上找到的示例根本没有帮助。
client.user.setActivity("what the bot is playing");
根本不起作用,它给了我这个错误,说明我正在尝试找到空的东西(不存在......用非编程术语来说)
TypeError: Cannot read properties of null (reading 'setActivity')
at Object.<anonymous> (/home/runner/DiscordBot/index.js:46:13)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
您可能正在尝试在机器人上线之前更改其状态。尝试将其放入就绪事件中。
client.on("ready", () => {
client.user.setActivity("what the bot is playing");
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)