我正在尝试让我的机器人在它上线/准备好的时候给我发一条直接消息
我曾尝试使用bot.guilds.members.find("id", "my id")和bot.guilds.members.get("id", "my id")等函数,但它只返回find/get is not a function
bot.on("ready", async message => {
bot.guilds.members.find("id", "my id")
});我想让机器人在上线时给我发一条消息
发布于 2019-08-15 00:18:35
bot.on("ready", async () => {
bot.users.get("Your ID").send("Message")
});发布于 2019-08-15 00:35:41
ready event没有提供任何参数(我希望这是正确的表述方式)。因此,您的回调函数的message参数是undefined,尝试读取通道时会出现"cannot read property‘message.channel’of undefined“错误。
这应该是可行的:
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");
});https://stackoverflow.com/questions/57498397
复制相似问题