'How can I make the channel.send know where its being sent

I tried messing around with it and couldn't get it to work - all I want is for it to send in the channel that the user initiated the bot to talk.

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}!`);
});


Solution 1:[1]

It's quite easy, in fact. If you haven't created the client.on("messageCreate", message => {}); event handler, I very strongly recommend creating it in the main file (if you use multiple files). Then, all you have to do is use message.channel.send(); inside those curly brackets {} to send message in the channel the user initiated the bot to talk. It's a good idea to check out the discord.js guide: https://discordjs.guide/#before-you-begin and watch YouTube tutorials on discord.js v13.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 panzer-chan