A
A
aihan2019-07-20 13:47:51
JavaScript
aihan, 2019-07-20 13:47:51

Discord bot in js?

What's wrong with this script?

bot.on("message", async message => {
    if(message.author.bot) return;
    if(message.channel.type === "dm") return;

    let prefix = botconfig.prefix;
    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);
    
    if(cmd === `${prefix}айхан`){
        client.channels.get(`599721171633700874`).send('My Message');
    }


});

The fact is that I don’t send a message to the channel that the id I indicated ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2019-07-21
@aihan

I can suggest trying to replace client.channelswith bot.channels
Or it's even easier to take the channel ID from the message itself

bot.on("message", async message => {
    if(message.author.bot) return;
    if(message.channel.type === "dm") return;

    let prefix = botconfig.prefix;
    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);
    
    bot.channels.get(message.channel.id).send('My message')
    .then(msg => {
      
    })
    .catch((e) => {
      console.log(e);
    });
});

K
Keenzhal, 2021-01-11
@Keenzhal

member.guild.channels.cache.get("ID").send(" Discord bot in js? ")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question