router.post('/process', async (request, env) => {
try {
const { isValid, interaction } = await server.verifyDiscordRequest(
request,
env,
);
if (!isValid || !interaction) {
console.error('Bad request signature.');
return new Response('Bad request signature.', { status: 401 });
}
if (interaction.type === InteractionType.PING) {
return new JsonResponse({
type: InteractionResponseType.PONG,
});
}
if (interaction.type === InteractionType.APPLICATION_COMMAND) {
// Permission Check
...
try {
// this call hangs with no errors logged
await createInteractionResponse(env, interaction, {
type: InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
data: {flags: InteractionResponseFlags.EPHEMERAL}
});
switch (interaction.data.name.toLowerCase()) {
case SET_LIMIT.name.toLowerCase(): {
await setLimitCommand(env, interaction);
return new Response(null, {status: 202});
}
...
router.post('/process', async (request, env) => {
try {
const { isValid, interaction } = await server.verifyDiscordRequest(
request,
env,
);
if (!isValid || !interaction) {
console.error('Bad request signature.');
return new Response('Bad request signature.', { status: 401 });
}
if (interaction.type === InteractionType.PING) {
return new JsonResponse({
type: InteractionResponseType.PONG,
});
}
if (interaction.type === InteractionType.APPLICATION_COMMAND) {
// Permission Check
...
try {
// this call hangs with no errors logged
await createInteractionResponse(env, interaction, {
type: InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
data: {flags: InteractionResponseFlags.EPHEMERAL}
});
switch (interaction.data.name.toLowerCase()) {
case SET_LIMIT.name.toLowerCase(): {
await setLimitCommand(env, interaction);
return new Response(null, {status: 202});
}
...