首页 > 解决方案 > 如何从值中获取“captureDate”并将其作为消息发送

问题描述

所以我在我的不和谐机器人中添加了一个功能来收集用户最近的游戏剪辑,目前我能够在我的控制台日志中收集所有信息,但很难理解如何在消息中发送它。我对这些东西很陌生。

这是我现在的代码片段:

    const userXuid = await XboxLiveAPI.getPlayerXUID(gamertag, authInfo).catch(err => message.reply('That gamertag could not be found. Make sure spaces are replaced with \'_\''));
    const scores = await XboxLiveAPI.getPlayerScreenshotsFromMediaHub(userXuid, authInfo, num);

    console.log(scores);

这就是返回到控制台的内容:

{
  continuationToken: 'YWJjZGVfdnd4eXoxMDA1',
  values: [ 
    {
      captureDate: '2016-09-13T19:11:11Z',
      contentId: 'e61118b6-c940-4hc9-a32a-49dd53ab4192',
      contentLocators: [Array],
      CreationType: 'Edited',
      localId: '501bf44b-c1b2-4519-b78e-a1f88097f8d1',
      ownerXuid: 25332749247888726,
      resolutionHeight: 720,
      resolutionWidth: 1280,
      sandboxId: 'RETAIL',
      sharedTo: [],
      titleId: 1129121809,
      titleName: 'OF: Dragon Rising',
      dateUploaded: '2016-09-13T19:12:34.6226406Z',
      uploadLanguage: 'en-GB',
      uploadRegion: 'GB',
      uploadTitleId: 201477059,
      uploadDeviceType: 'XboxOne',
      commentCount: 0,
      likeCount: 0,
      shareCount: 0,
      viewCount: 2,
      contentState: 'Published',
      enforcementState: 'None',
      safetyThreshold: 'None',
      sessions: [],
      tournaments: []
    }
  ]
}

结论

那么,例如,我将如何让 captureDate 发送:

message.channel.send(???)

任何帮助将不胜感激,干杯!

标签: javascriptnode.jsarrayspromisediscord.js

解决方案


如果您只是在谈论访问 captureDate,您将使用scores.values[0].captureDate.


推荐阅读