【问题标题】:How to get 'captureDate' from values and send it as a message如何从值中获取“captureDate”并将其作为消息发送
【发布时间】:2020-10-30 15:29:15
【问题描述】:

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

这是我现在的代码的 sn-p:

    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(???)

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

【问题讨论】:

    标签: javascript node.js arrays promise discord.js


    【解决方案1】:

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

    【讨论】:

    • 为这个飞旭干杯:)
    猜你喜欢
    • 2020-12-13
    • 2016-05-19
    • 2021-02-17
    • 2022-01-10
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 2023-01-22
    • 2021-01-10
    相关资源
    最近更新 更多