-
Notifications
You must be signed in to change notification settings - Fork 1
/
getWeeklyLinks.js
41 lines (38 loc) · 947 Bytes
/
getWeeklyLinks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { getWeek } = require('date-fns')
const db = require('../../../prisma/prismaClient')
async function getWeeklyLinks(message, city) {
try {
const links = await db.link.findMany({
where: {
weekNo: getWeek(new Date()),
campus: {
is: {
city: city,
},
},
},
include: {
wilder: {
select: {
username: true,
},
},
},
})
return message.channel.send({
embed: {
thumbnail: {
url: 'https://avatars.githubusercontent.com/u/8874047?s=280&v=4',
},
title: `**The weekly tech watch for ${city} !**`,
fields: links.map(({ link, wilder }, i) => {
return { name: `${i + 1}: ${wilder.username}`, value: link }
}),
},
})
} catch (error) {
console.error(error)
return message.channel.send(error)
}
}
module.exports = getWeeklyLinks