View current week's tasks from Todoist

I use Todoist as my main todo app. This is a script I can use to view all of the tasks I want to get done in the next 7 days.

Screen Shot 2021-04-25 at 12 51 41 AM

Code

// Menu: Todoist Tasks
// Description: View this week's tasks from Todoist
// Author: Benjamin Lannon
// Twitter: @lannonbr
/** @type typeof import('todoist') */
const todoistPackage = await npm("todoist");
/** @type typeof import('dayjs') */
const dayjs = await npm("dayjs");
// API Token can be found here: https://todoist.com/prefs/integrations
const token = await env("TODOIST_TOKEN");
const client = todoistPackage.v8(token);
await client.sync();
let items = client.items.get();
items = items.filter((item) => {
let dueDate = dayjs(item.due.date);
return dueDate.diff(dayjs(), "day") <= 7;
});
await arg(
"View this week's tasks",
items.map((item) => {
return {
name: item.content,
description: `Due: ${item.due.date}`,
};
})
);