-
Notifications
You must be signed in to change notification settings - Fork 9
/
get.js
51 lines (44 loc) · 1.37 KB
/
get.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
42
43
44
45
46
47
48
49
50
51
import { transcript, initBot } from '../utils'
//import * as githubGrant from './promos/githubGrant'
// import * as hackPack from './promos/hackPack'
import * as stickerEnvelope from './promos/stickerEnvelope'
// import * as notionPremium from './promos/notionPremium'
import * as stickermule from './promos/stickermule'
// import * as adafruitDiscount from './promos/adafruitDiscount'
import * as zoom from './promos/zoom'
import * as replitHackerPlan from './promos/replitHackerPlan'
const promos = [
stickerEnvelope,
// notionPremium,
stickermule,
// hackPack,
//githubGrant,
replitHackerPlan,
// adafruitDiscount,
zoom,
]
const interactionGet = async (bot = initBot(), message) => {
const args = message.text.toLowerCase()
if (args == 'help') {
await bot.replyPrivateDelayed(message, transcript('get.help'))
return
}
const selectedPromo = promos.find(promo => {
const promoMatchers = promo.names.map(t => t.toLowerCase())
return promoMatchers.find(matcher => args.indexOf(matcher) === 0)
})
if (selectedPromo) {
try {
await selectedPromo.run(bot, message)
} catch (err) {
console.error(err)
await bot.replyPrivateDelayed(
message,
transcript('errors.general', { err })
)
}
} else {
await bot.replyPrivateDelayed(message, transcript('get.list', { promos }))
}
}
export default interactionGet