INNER CODE UNIT · JavaScript
taskKeys
nyxxbit/discord-quest-completer · index.js:280
const taskKeys = (tasks) => (tasks instanceof Map ? [...tasks.keys()] : Object.keys(tasks ?? {}));
const taskAt = (tasks, key) => (tasks instanceof Map ? tasks.get(key) : tasks?.[key]);
// Discord's current taskConfigV2 is authoritative when it carries tasks. Some payloads keep
// the legacy taskConfig beside it, and nullish-coalescing legacy first routes the quest
// through stale task/app metadata, which is how this script and the plugin could reach
// different answers about the same quest. Same rule as selectQuestTaskConfig in
// questConfig.ts, which has regression tests for it.
const selectTaskConfig = (config) => {
const current = config?.taskConfigV2;
if (taskKeys(current?.tasks).length > 0) return current;
const legacy = config?.taskConfig;
if (taskKeys(legacy?.tasks).length > 0) return legacy;
return current ?? legacy ?? null;
};
// Task keys Discord validates somewhere this script cannot reach, mapped to why.
// ACHIEVEMENT_IN_GAME is not ACHIEVEMENT_IN_ACTIVITY: no embedded activity, no discordsays