第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何記錄用戶輸入以在以后嵌入 discordjs 時(shí)使用

如何記錄用戶輸入以在以后嵌入 discordjs 時(shí)使用

哈士奇WWW 2021-08-20 18:12:09
我正在制作一個(gè)傭金機(jī)器人,所以人們打開一張票,然后選擇它的類別,但然后我希望它要求預(yù)算等待回復(fù),然后存儲該輸入預(yù)算以用于嵌入以發(fā)布給自由職業(yè)者。我已經(jīng)嘗試將其存儲為常量然后稍后調(diào)用它,但它不想工作,因?yàn)槲覍⑺鎯υ诓煌暮瘮?shù)中。msg.channel.awaitMessages(filter, { time: 60000, maxMatches: 1, errors: ['time'] })        .then(messages => {            msg.channel.send(`You've entered: ${messages.first().content}`);            const budget = messages.first().content;        })        .catch(() => {            msg.channel.send('You did not enter any input!');        });});    if (messageReaction.emoji.name === reactions.one) {        let web = new Discord.RichEmbed()        .setDescription("Press the check to claim the comission")        .setColor("#15f153")        .addField("Client", `${message.author} with ID: ${message.author.id}`)        .addField("Budget", `${budget}`)        .addField("Time", message.createdAt)        .addField("Requested Freelancer",`<@&603466765594525716>`)        let tickets = message.guild.channels.find('name', "tickets")        if(!tickets) return message.channel.send(`${message.author} Can't find tickets channel.`)我希望它在 .addField 預(yù)算部分發(fā)布預(yù)算,但它只是說預(yù)算未定義
查看完整描述

2 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

您是const budget在不同于全局范圍的范圍內(nèi)定義 的(有關(guān)范圍,請參閱此頁面)。


這個(gè)答案解釋了聲明、變量和范圍如何協(xié)同工作。


在這里,您budget僅在awaitMessages.then范圍內(nèi)可用,即


.then(messages => {

  msg.channel.send(`You've entered: ${messages.first().content}`);

  const budget = messages.first().content;

  // the const is only know there

})

但是,該then塊將返回一個(gè)值。因?yàn)椴辉儆墟準(zhǔn)匠兄Z(除非有錯(cuò)誤,因?yàn)樗鼤|發(fā)鏈?zhǔn)絚atch)。在此處了解有關(guān) promise 的更多信息。


有用的是,一旦承諾被解決,msg.channel.awaitMessages將返回一個(gè)值。


然后你可以做兩件事:


等待 的響應(yīng)msg.channel.awaitMessages,將其分配給變量并稍后使用

鏈接另一個(gè)承諾

等待:


let budget = await msg.channel.awaitMessages(filter, { time: 60000, maxMatches: 1, errors: ['time'] })

  .then(messages => {

    msg.channel.send(`You've entered: ${messages.first().content}`);

    return messages.first().content;

  })

  .catch(() => {

    msg.channel.send('You did not enter any input!');

  });

});


if (messageReaction.emoji.name === reactions.one) {

  let web = new Discord.RichEmbed()

    .setDescription("Press the check to claim the comission")

    .setColor("#15f153")

    .addField("Client", `${message.author} with ID: ${message.author.id}`)

    .addField("Budget", `${budget}`)

    .addField("Time", message.createdAt)

    .addField("Requested Freelancer",`<@&603466765594525716>`)

 let tickets = message.guild.channels.find('name', "tickets")

 if(!tickets) return message.channel.send(`${message.author} Can't find tickets channel.`)

// ...

}

鏈接:


msg.channel.awaitMessages(filter, { time: 60000, maxMatches: 1, errors: ['time'] })

  .then(messages => {

    msg.channel.send(`You've entered: ${messages.first().content}`);

    return messages.first().content;

  })

  .then((budget) => {

    if (messageReaction.emoji.name === reactions.one) {

      let web = new Discord.RichEmbed()

        .setDescription("Press the check to claim the comission")

        .setColor("#15f153")

        .addField("Client", `${message.author} with ID: ${message.author.id}`)

        .addField("Budget", `${budget}`)

        .addField("Time", message.createdAt)

        .addField("Requested Freelancer",`<@&603466765594525716>`)

      let tickets = message.guild.channels.find('name', "tickets")

      if(!tickets) return message.channel.send(`${message.author} Can't find tickets channel.`)

      // ...

    }

  })

  .catch(() => {

    msg.channel.send('You did not enter any input!');

  });


查看完整回答
反對 回復(fù) 2021-08-20
  • 2 回答
  • 0 關(guān)注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號