简体   繁体   中英

How can I get a message from a member then send it to a channel

If the member sends randomize ${text} , I want the bot to send Your choice is ${text}

const collec = new Discord.MessageCollector(channelfilteroptions);

const text = collec.collect();

client.on("message", (message) => {
    if (!message.guild) return;
    if (message.author.bot) return;
    if (message === `randomize ${text}`) {
        message.channel.send(`u send ${text}`);
    }
});

This will only replace the first "randomize" found in your string, so if for some reason the user enters "randomize randomize", it will send "You sent randomize"

const text = message.content.replace('randomize', '');
message.channel.send(`You sent ${text});


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM