not EPHEMERAL because no embeds

This commit is contained in:
Kalle (Sendou) 2020-12-23 13:07:48 +02:00
parent 0d7188a497
commit 4e3364bda7
4 changed files with 9 additions and 14 deletions

View File

@ -1,12 +1,9 @@
import getEmbed from "discord/embed";
import { weaponsToEmoji } from "discord/emoji";
import { RespondData } from "discord/utils";
import { RespondFuction } from "discord/utils";
import { getUserByIdentifier } from "prisma/queries/getUserByIdentifier";
const infoCommand = async (
respond: (result: RespondData) => void,
discordId: string
) => {
const infoCommand = async (respond: RespondFuction, discordId: string) => {
const user = await getUserByIdentifier(discordId);
if (!user) {

View File

@ -1,9 +1,9 @@
import infoCommand from "./commands/info";
import { InteractionInfo, InvocationCommon, RespondData } from "./utils";
import { InteractionInfo, InvocationCommon, RespondFuction } from "./utils";
const handleCommand = async (
interaction: InvocationCommon & InteractionInfo,
respond: (result: RespondData) => void
respond: RespondFuction
) => {
switch (interaction.data.name) {
case "ping":

View File

@ -27,3 +27,5 @@ export type RespondData = {
content?: string;
embeds?: Embed[];
};
export type RespondFuction = (result: RespondData) => void;

View File

@ -1,9 +1,5 @@
import handleCommand from "discord";
import {
InteractionResponseFlags,
InteractionResponseType,
InteractionType,
} from "discord-interactions";
import { InteractionResponseType, InteractionType } from "discord-interactions";
import { RespondData } from "discord/utils";
import { NextApiRequest, NextApiResponse } from "next";
import getRawBody from "raw-body";
@ -43,7 +39,7 @@ const discordCommandHandler = async (
if (interaction && interaction.type === InteractionType.COMMAND) {
handleCommand(interaction, (data) =>
res.status(200).json({
type: InteractionResponseType.CHANNEL_MESSAGE,
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: getCompleteData(data),
})
);
@ -59,7 +55,7 @@ function getCompleteData(result: RespondData) {
...result,
// add zero-width space because empty content isn't allowed even with embeds
content: result.content ? result.content : "\u200b",
flags: InteractionResponseFlags.EPHEMERAL,
//flags: InteractionResponseFlags.EPHEMERAL,
};
}