fix: interaction app_permissions field
This commit is contained in:
parent
41bdb5566b
commit
83245998c4
@ -20,7 +20,7 @@ import { randomBytes } from "crypto";
|
|||||||
import { InteractionSchema } from "@spacebar/schemas";
|
import { InteractionSchema } from "@spacebar/schemas";
|
||||||
import { route } from "@spacebar/api";
|
import { route } from "@spacebar/api";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { emitEvent, Guild, InteractionCreateEvent, InteractionFailureEvent, InteractionType, Member, Message, Snowflake, User } from "@spacebar/util";
|
import { emitEvent, getPermission, Guild, InteractionCreateEvent, InteractionFailureEvent, InteractionType, Member, Message, Snowflake, User } from "@spacebar/util";
|
||||||
import { pendingInteractions } from "@spacebar/util/imports/Interactions";
|
import { pendingInteractions } from "@spacebar/util/imports/Interactions";
|
||||||
import { InteractionCreateSchema } from "@spacebar/schemas/api/bots/InteractionCreateSchema";
|
import { InteractionCreateSchema } from "@spacebar/schemas/api/bots/InteractionCreateSchema";
|
||||||
|
|
||||||
@ -50,7 +50,6 @@ router.post("/", route({}), async (req: Request, res: Response) => {
|
|||||||
type: body.type,
|
type: body.type,
|
||||||
token: interactionToken,
|
token: interactionToken,
|
||||||
version: 1,
|
version: 1,
|
||||||
app_permissions: "0", // TODO: add this later
|
|
||||||
entitlements: [],
|
entitlements: [],
|
||||||
authorizing_integration_owners: { "0": req.user_id },
|
authorizing_integration_owners: { "0": req.user_id },
|
||||||
attachment_size_limit: 0, // TODO: add this later
|
attachment_size_limit: 0, // TODO: add this later
|
||||||
@ -67,6 +66,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
|
|||||||
if (body.guild_id) {
|
if (body.guild_id) {
|
||||||
interactionData.context = 0;
|
interactionData.context = 0;
|
||||||
interactionData.guild_id = body.guild_id;
|
interactionData.guild_id = body.guild_id;
|
||||||
|
interactionData.app_permissions = (await getPermission(body.application_id, body.guild_id, body.channel_id)).bitfield.toString();
|
||||||
|
|
||||||
const guild = await Guild.findOneOrFail({ where: { id: body.guild_id } });
|
const guild = await Guild.findOneOrFail({ where: { id: body.guild_id } });
|
||||||
const member = await Member.findOneOrFail({ where: { guild_id: body.guild_id, id: req.user_id }, relations: ["user"] });
|
const member = await Member.findOneOrFail({ where: { guild_id: body.guild_id, id: req.user_id }, relations: ["user"] });
|
||||||
@ -81,6 +81,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
|
|||||||
interactionData.member = member.toPublicMember();
|
interactionData.member = member.toPublicMember();
|
||||||
} else {
|
} else {
|
||||||
interactionData.user = user.toPublicUser();
|
interactionData.user = user.toPublicUser();
|
||||||
|
interactionData.app_permissions = (await getPermission(body.application_id, "", body.channel_id)).bitfield.toString();
|
||||||
|
|
||||||
if (body.channel_id === body.application_id) {
|
if (body.channel_id === body.application_id) {
|
||||||
interactionData.context = 1;
|
interactionData.context = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user