【问题标题】:How to create a trello card using a discord bot如何使用不和谐机器人创建 trello 卡
【发布时间】:2020-01-10 18:41:05
【问题描述】:

我对 Java 脚本编码非常陌生。我正在尝试制作一个机器人来将卡片添加到我的 trello 中,我在互联网上花费了无数个小时,但我没有找到它。

   if(isCommand('gameban', message)){
       if(!message.member.roles.some(r=>["Admin"].includes(r.name)) )
   return message.reply("You can't use this command.");
    var username = args[1]
    if (username){
        message.channel.send(`Checking ROBLOX for ${username}`)
        roblox.getIdFromUsername(username)          
            .then(function(id){
                var bandata = (`${username}:${id}`)
                //this is where the code needs to go for trello. The card name should be is "bandata"
            }).catch(function(err){
                message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
    });
    return;
   }}

董事会:https://trello.com/b/KcRBCOQQ/secondary-board

我希望卡片进入标有“禁令”的列表

【问题讨论】:

    标签: javascript node.js discord discord.js trello


    【解决方案1】:

    你可以试试trello-node-api

    npm install trello-node-api --save

    var trelloNode = require('trello-node-api')(apiKey, oauthToken);
    
    
    var data = {
            name: 'CARD_NAME',
            desc: 'Card description',
            pos: 'top',
            idList: 'LIST_ID', //REQUIRED
            due: null,
            dueComplete: false,
            idMembers: ['MEMBER_ID', 'MEMBER_ID', 'MEMBER_ID'],
            idLabels: ['LABEL_ID', 'LABEL_ID', 'LABEL_ID'],
            urlSource: 'https://example.com',
            fileSource: 'file',
            idCardSource: 'CARD_ID',
            keepFromSource: 'attachments,checklists,comments,due,labels,members,stickers'
        };
        Trello.card.create(data).then(function (response) {
            console.log('response ', response);
        }).catch(function (error) {
            console.log('error', error);
        });
    

    【讨论】:

    • 您好,每次我测试代码时,它都会直接出现功能错误}).catch(function(err){ message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`) 你能给我举个例子吗?
    • 您应该console.error(err) 错误,而不是仅仅作为对频道的非描述性错误进行响应。它会告诉你为什么它总是出错。
    • 它没有向我显示错误,它只会归结为找不到用户。
    猜你喜欢
    • 2020-09-06
    • 2021-04-10
    • 2020-12-28
    • 2019-03-28
    • 2020-04-29
    • 2017-12-29
    • 2020-11-29
    • 1970-01-01
    • 2018-03-20
    相关资源
    最近更新 更多