我试着摆弄它,却没能让它正常工作--我只想让它发送用户启动的bot对话频道。
client.once('ready', async () => {
// [beta]
const storedBalances = await Users.findAll();
storedBalances.forEach(b => currency.set(b.user_id, b));
client.channels.fetch("/*the channel where channel.send will go to*/").then((c) => {
channel = c;
})
console.log(`Logged in as ${client.user.tag}!`);
});发布于 2022-04-07 01:52:50
事实上,这很容易。如果您还没有创建client.on("messageCreate", message => {});事件处理程序,我强烈建议在主文件中创建它(如果您使用多个文件)。然后,您所要做的就是在那些花括号中使用message.channel.send();在用户发起的bot对话的通道中发送消息。查看discord.js指南是个好主意:https://discordjs.guide/#before-you-begin和观看YouTube关于discord.js v13的教程。
https://stackoverflow.com/questions/71775363
复制相似问题