-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tsx
66 lines (60 loc) · 1.72 KB
/
main.tsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { Client, Intents } from "discord.js"
import "dotenv/config.js"
import { ReacordDiscordJs } from "reacord"
import React from "react"
import { RollResultView } from "./dice/roll-result.js"
import { useCommands } from "./helpers/commands.js"
import { Logger } from "./helpers/logger.js"
import { RpsView } from "./rps/rps-view.js"
const client = new Client({ intents: [Intents.FLAGS.GUILDS] })
const reacord = new ReacordDiscordJs(client)
const logger = new Logger("[bae]")
useCommands(client, [
{
type: "CHAT_INPUT",
name: "roll",
description: "rolls a dice",
options: [
{
name: "dice",
description: "dice to roll",
type: "STRING",
required: true,
},
],
run(interaction) {
reacord.reply(
interaction,
<RollResultView
diceString={interaction.options.getString("dice") || "1d6"}
userId={interaction.user.id}
isReroll={false}
/>,
)
},
},
{
type: "USER",
name: "Rock, Paper, Scissors",
run(interaction) {
const challenger = interaction.user
const challenged = interaction.targetUser
if (challenger.id === challenged.id) {
return interaction.reply(`You can't challenge yourself, silly.`)
}
const isSelf = challenged.id === client.user?.id
if (challenged.bot && !isSelf) {
return interaction.reply(
`You can't challenge another bot, the tech isn't there yet. But try challenging me!`,
)
}
reacord.reply(
interaction as any,
<RpsView player1={challenger} player2={challenged} isSelf={isSelf} />,
)
},
},
])
await client
.on("ready", () => logger.info("ready"))
.login(process.env.BOT_TOKEN)