forked from hackclub/toriel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-welcome-committee.js
33 lines (31 loc) · 983 Bytes
/
post-welcome-committee.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
const { prisma } = require('../db')
const { transcript } = require('../util/transcript')
const { client } = require('../app')
async function postWelcomeCommittee(user) {
try {
const slackuser = await client.users.info({ user })
const email = slackuser?.user?.profile?.email
const invite = await prisma.invite.findFirst({
where: { email },
orderBy: { createdAt: 'desc' },
})
const message =
invite?.['welcome_message'] || "I'm using the /toriel-restart command"
const continent = invite?.['continent'] || 'DEFAULT_CONTINENT'
const hs = invite ? invite.high_school : true
const event = invite ? invite.event : null
await client.chat.postMessage({
channel: transcript('channels.welcome-committee'),
text: transcript('welcome-committee', {
user,
message,
continent,
hs,
event,
}),
})
} catch (e) {
console.log(e)
}
}
module.exports = { postWelcomeCommittee }