I want to create a global chat with discord.js

Asked 1 years ago, Updated 1 years ago, 67 views

Global chat on Node.js discord.js (I want to do something that says "a" on Channel B of A mackerel and "a" on Channel D of C mackerel, but I can't do it well.
Please tell me what's wrong.

Code I tried making

client.on('message',message=>{
    if(message.author.bot){
        return;
   }
    if(message.channel.name==='d-global-chat'){
        let args = message.content.split("").slice(1);
        client.channels.find("name", "d-global-chat").send(args.join(""));
    }
});

javascript node.js discord

2022-09-30 10:55

1 Answers

It's not cool, but I think it's better to specify the ID of the server and channel ID.
(After that, you have to put the bot in each mackerel.)

if(message.channel.name==="A mackerel channel name"){
    let message2 = message.content.toString();
    return client.guilds.get("A mackerel ID").channels.get("A mackerel channel ID").send(`${message.author.username}<`+`${message2}`);
}
if(message.channel.name==="B mackerel channel name"){
    return client.guilds.get("B mackerel ID").channels.get("B mackerel channel ID").send(`${message.author.username}<`+`${message}`);
}

I'm sorry......I don't understand if I tie more than three mackerels...


2022-09-30 10:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.