Skip to content

Commit

Permalink
fix: Fix using defer (#50)
Browse files Browse the repository at this point in the history
* fix: Fix using defer

* Format
  • Loading branch information
MikuroXina authored Oct 13, 2023
1 parent 7ddc403 commit 99a16e4
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ const errorResponse = (reason: string) => ({
},
});

const sendResponse = (
{ interactionId, interactionToken, content }: {
interactionId: string;
interactionToken: string;
content: string;
},
) =>
fetch(
[
ENDPOINT,
"interactions",
interactionId,
interactionToken,
"callback",
].join("/"),
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ content }),
},
);

const editSentResponse = (
{ applicationId, interactionToken }: {
applicationId: string;
Expand Down Expand Up @@ -136,11 +112,6 @@ async function pinMessage(
interaction: Interaction,
options: WebhookOptions,
) {
await sendResponse({
interactionId: interaction.id,
interactionToken: interaction.token,
content: "ピン留め中…",
});
const editSent = editSentResponse({
applicationId: options.applicationId,
interactionToken: interaction.token,
Expand Down Expand Up @@ -215,6 +186,9 @@ export const makeCommands = (options: WebhookOptions): InteractionHandlers => [

return {
type: InteractionResponseType.DeferredChannelMessageWithSource,
data: {
content: "ピン留め中…",
},
};
},
],
Expand Down

0 comments on commit 99a16e4

Please sign in to comment.