我正在尝试让我的机器人在联机/准备就绪时向我发送直接消息
我尝试使用诸如bot.guilds.members.find("id", "my id")
和bot.guilds.members.get("id", "my id")
但它只是返回 find/get 不是一个函数
bot.on("ready", async message => {
bot.guilds.members.find("id", "my id")
});
我希望机器人在联机时向我发送消息
bot.on("ready", async () => {
bot.users.get("Your ID").send("Message")
});
ready 事件不提供任何参数(我希望这是正确的表达方式(。所以你的回调函数的message
参数是undefined
,尝试读取message.channel
会给你"无法读取未定义的属性'通道'"错误。
这应该有效:
const Client = new Discord.Client();
Client.login("YOUR TOKEN");
Client.on("ready", async () => {
let botDev = await Client.fetchUser("YOUR ID");
botDev.send("YOUR PRIVATE MESSAGE");
});