-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Command to Pull Daily and Weekly Activities from Destiny #16
Comments
Just had a look under the debugger - try changing the loop in
The |
Ok. If I have time during lunch, I will play with it. If not, when I get On Wed, Aug 24, 2016, 9:25 AM Scott Deakin notifications@github.com wrote:
|
Alright, had a some time to work on this at work and here's where I'm at. To access the other properties of the advisors object, you have to explicitly call them. Ex: Now, on to the next frustrating part... If you use the iteration I used this morning, you would think that you should be able to do the following: // I captured an example API response to a JSON file
var res = require('./activities.json');
var activities = res.Response.data.activities;
for (let activity in activities) {
/** activity should contain the property title of each activity property
* held in the API response object.
* prisonofelders, elderchallenge, trials, armsday, weeklycrucible, etc...
*/
console.log(activities + '.' + activity + '.' + status.active);
} But this merely returns the following error: c:\sites\objects\main.js:33
console.log(activities + '.' + activity + '.' + status.active);
^
ReferenceError: status is not defined I am sure that I am doing something stupid and elementary wrong, but like you... still pretty new to JavaScript and this is only maybe my third all out JavaScript project. This is one of those moments when you say to yourself, "Self! This would be so much easier in the language I am used to!" But sticking it out and working through this is how we learn I guess. LOL. I will get it. |
From reading the structure above, I think you may have wanted something like this:
|
Ok! I see what's going on... Not all the properties have the status.active that I was testing for. Weird. Now I know why there the following comment in the API docs: V2 features contracts that are 40% less shitty. The following still fails though... 'use strict'
var res = require('./response.json');
var activities = res.Response.data.activities;
/**
* Returns Prison of Elders
*/
console.log(activities.prisonofelders.display.advisorTypeCategory);
for (let activity in activities) {
console.log(activities.activity.display.advisorTypeCategory);
} Error: $ node index.js
Prison of Elders
C:\sites\objects\index.js:12
console.log(activities.activity.display.advisorTypeCategory);
^
TypeError: Cannot read property 'display' of undefined Which basically means that $ node index.js
prisonofelders
elderchallenge
trials
armsday
weeklycrucible
kingsfall
vaultofglass
crota
nightfall
heroicstrike
dailychapter
dailycrucible
prisonofelders-playlist
ironbanner
xur
srl So, it works. At this point I think you can see my confusion as to why the var activity created in the for...in loop returns something accessing it alone, but not when using it to access properties inside the object. Just weird. |
Playing with this before work, I tried the following: 'use strict'
var res = require('./response.json');
var activities = res.Response.data.activities;
var list = [];
//console.log(activities.prisonofelders.display.advisorTypeCategory);
for (let activity in activities) {
list.push(activity);
}
for (var i = 0; i < list.length; i++) {
//console.log(list[i]); spits my list back out, as before
console.log(activities.list[i].display.advisorTypeCategory);
} And it fails with: C:\sites\objects\index.js:16
console.log(activities.list[i].display.advisorTypeCategory);
^
TypeError: Cannot read property '0' of undefined At this point, I am going to separate this out into independent methods based on user input. So! The user will enter |
hmm... in the above code you are |
Sorry for the delayed response. Internet is down again, but that's not stopping me from working on this. Yes, that's what I meant to write, since activities contains the first part of the object structure. It's sorta mute now though. As I mentioned earlier, I am going to split this up into separate cmds. No biggie. |
Ok... got it sorted this morning and found the error of my ways. The variable that I want to place with the string of a property has to use "bracket notation" and not "dot notation". So, instead of this: for (let activity in activities) {
console.log(activities.activity.display.advisorTypeCategory);
} I should've been doing this: for (let activity in activities) {
console.log(activities[activity].display.advisorTypeCategory);
} Anyway, I will never forget this lesson! EVER! Moving forward. Now that I have proper internet again, I will perform a pull (to bring in any updates and changes to the project) . Shouldn't affect me since most everything I am working with is being created from scratch, aside from the DestinyAPI and Still going looking at breaking out each activity into it's own separate response. Some will be easier to put together than others, but in the end, These can be really long and the 2000 character limit in Discord might cause multiple DM's being sent. That would get messy to say the least. |
Looking good! Regarding the 2000 character limit, take a look in
If you look at some of the other commands that I have updated to use the above, you will see how they are used. In brief:
|
Trials and Daily Chapter are done. Was going to submit a pull request, for nothing else but to document progress, but apparently something has gone out of sync between the Master branch and my Destiny_Advisor branch. Will investigate that tonight before moving forward. Not worth the hassle at this time. Simple enough for me to delete my branch and start a new one if need be. |
happy to figure out the delta's if you want to submit a pull request |
just merged the latest advisor code into master as it seems stable |
Should've done this long ago... 💩 |
Create a cmd that the user can use to pull in daily and weekly Destiny activities, such as Daily bounties, Daily story missions, Daily crucible bounties and playlists.
The text was updated successfully, but these errors were encountered: