-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.ts
More file actions
36 lines (31 loc) · 1.38 KB
/
bot.ts
File metadata and controls
36 lines (31 loc) · 1.38 KB
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
import { InteractionResponseType, InteractionType } from "discord-interactions";
import { Request, Response } from "express";
export const handleBot = async (req: Request, res: Response) => {
const interaction = req.body;
if (interaction.type != InteractionType.APPLICATION_COMMAND) return
if (interaction.data.name == "ava") {
const userId = interaction.data.options.find(o => o.name == "user").value
const format = interaction.data.options.find(o => o.name == "format")?.value
const size = interaction.data.options.find(o => o.name == "size")?.value
let url = `https://ava.viadev.xyz/${userId}`
if (format) url += `.${format}`
if (size) url += `?size=${size}`
return res.send({
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
content: `${url} .`,
},
})
}
if (interaction.data.name == "emoji") {
const parts = interaction.data.options.find(o => o.name == "emoji").value.split(":")
const id = parts[2]
if (id == undefined || id.length < 9) return
return res.send({
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
content: `https://cdn.discordapp.com/emojis/${id.slice(0, id.length - 1)}${parts[0] == "<a" ? ".gif" : ""} .`,
},
})
}
}