简体   繁体   中英

Discord.js put words in embed

const raidembed = new DiscordJS.MessageEmbed()
  .setTitle(`Raid Target`)
  .setDescription(`
    Location: ${the text}
    Sulfur Needed: ${the text}
  `)
message.channel.send(raidembed)

How would I save messages and put them into the embed?

Like so

Bot: Location? 
Me: <text>
Bot: Sulfur needed?
Me: <etc>
Bot: embed

You can use collectors to ask the user for the response.

const collector = new Discord.MessageCollector(
    message.channel,
    (m) => m.author.id === message.author.id,
    { time: 100000 }
);
var location, sulfur;
collector.on("collect", (message2) => {
    //asks
    const colorval = message.content.toUpperCase();
      location = colorval;
      collector.stop();
});

This sample code pretty much waits for the user to respond, it checks to make sure the author is the same as the author of the initial message. Then, it saves the user's second message to a variable, "location". I've done the first part, but all you have to do is just add another collector to ask for "sulfur needed?" and then you can just send a regular message at the end of the code.

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