apprev/src/joinRequestActions/interview.ts

37 lines
1.1 KiB
TypeScript

import { ComponentTypes, InteractionTypes, MessageFlags } from "oceanic.js";
import { client } from "..";
import { canUser } from "../utils/utils";
import { selfappReq } from "../utils/selfappReq";
client.on("interactionCreate", async (interaction) => {
if (interaction.type === InteractionTypes.MESSAGE_COMPONENT)
if (interaction.data.componentType === ComponentTypes.BUTTON) {
if (interaction.data.customID.split("-")[0] === "interview") {
await interaction.defer(MessageFlags.EPHEMERAL);
if (!canUser(interaction.member!, "review"))
return await interaction.createFollowup({
flags: MessageFlags.EPHEMERAL,
content: "💢 nop"
});
const gdmID = (
(await selfappReq(
`/join-requests/${
interaction.data.customID.split("-")[1]
}/interview`,
"POST"
)) as any
).id;
const gdmInvite = (
(await selfappReq(
`/channels/${gdmID}/invites`,
"POST"
)) as any
).code;
return await interaction.createFollowup({
flags: MessageFlags.EPHEMERAL,
content: `https://discord.gg/${gdmInvite}`
});
}
}
});