简体   繁体   English

有没有办法在使用 JavaScript 创建 Trello 卡片时获取它的 ID?

[英]Is there any way to get the ID of a Trello card upon creating it using JavaScript?

So, I'm making a Discord Bot which has an integrated Trello board.所以,我正在制作一个带有集成 Trello 板的 Discord Bot。 My aim is for the bot to add a card and then respond with the card's id.我的目标是让机器人添加一张卡片,然后用卡片的 ID 进行响应。 I found Trello.card.getId() but it's a different language seemingly and returns that getId() isn't a function.我找到了Trello.card.getId()但它似乎是一种不同的语言,并返回 getId() 不是函数。

Full code for create function:创建函数的完整代码:

Trello.card.create(data).then(function(response){
    console.log('Trello card has been added!');
    msg.reply('Trello card has been successfully added!');
    console.log("Card ID:"+Trello.card.getId())
  }).catch(function(error){
    console.log('Error: ',error)
  });

Using JavaScript.使用 JavaScript。

Managed to find it!设法找到了! To do this, use the following:为此,请使用以下命令:

    console.log('Trello card has been added!');
    msg.reply('Trello card has been successfully added!');
    msg.reply(response.id);
    console.log(response);
  }).catch(function(error){
    console.log('Error: ',error)
  });

Specifically, note "msg.reply(response.id); Response finds all the information in the card, and .id specifies what to get FROM the response. Hopefully this helps everyone else as much as it helped me. I suggest using console.log(response) to see what sort of other things you can get upon creating the card. :)具体来说,请注意“msg.reply(response.id); Response 查找卡片中的所有信息,而 .id 指定从响应中获取什么。希望这对其他人有帮助,也对我有帮助。我建议使用console.log(response)以查看创建卡片时可以获得哪些其他内容。:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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