mchangrh / sb-slash

Sponsorblock with discord slash commands
https://sb-slash.mchang.workers.dev/invite
GNU General Public License v3.0
7 stars 6 forks source link

The bot ignores text messages #21

Closed NatoBoram closed 2 years ago

NatoBoram commented 2 years ago

I'm trying to use the bot, but it doesn't give me commands to use

image

Since I can't send messages of type body.type == InteractionType.APPLICATION_COMMAND for some reason, the bot completely ignores me when I try to use commands.

The issue starts at the bottom of this code

// Process a Discord interaction POST request
const handleInteraction = async ({ request, wait }) => {
  // Get the body as a buffer and as text
  const bodyBuffer = await request.arrayBuffer();
  const bodyText = (new TextDecoder("utf-8")).decode(bodyBuffer);

  // Verify a legitimate request
  if (!handleInteractionVerification(request, bodyBuffer))
    return new Response(null, { status: 401 });

  // Work with JSON body going forward
  const body = JSON.parse(bodyText);

  // Handle a PING
  if (body.type === InteractionType.PING)
    return jsonResponse({
      type: InteractionResponseType.PONG
    });
  try {
    if (body.type == InteractionType.APPLICATION_COMMAND) { // handle commands