Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Discord plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • interactions
    • applicationCommand (interactions.applicationCommand)
    • messageComponent (interactions.messageComponent)
    • modalSubmit (interactions.modalSubmit)
    • ping (interactions.ping)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Interactions

Application Command

interactions.applicationCommand A user invoked a slash command or context-menu action Payload
NameTypeRequiredDescription
idstringYes
application_idstringYes
tokenstringYes
version1Yes
guild_idstringNo
channel_idstringNo
memberobjectNo
userobjectNo
localestringNo
guild_localestringNo
app_permissionsstringNo
type2Yes
dataobjectYes
{
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  nick?: string | null,
  roles: string[],
  joined_at: string,
  permissions: string,
  deaf: boolean,
  mute: boolean
}
{
  id: string,
  username: string,
  discriminator: string,
  global_name?: string | null,
  avatar?: string | null,
  bot?: boolean,
  system?: boolean,
  email?: string | null,
  verified?: boolean,
  locale?: string,
  premium_type?: number,
  public_flags?: number,
  flags?: number
}
{
  id: string,
  name: string,
  type: number,
  options?: {
    name: string,
    type: number,
    value?: string | number | boolean,
    focused?: boolean,
    options?: lazy
  }[],
  guild_id?: string,
  target_id?: string
}
{
  id: string,
  application_id: string,
  token: string,
  version: 1,
  guild_id?: string,
  channel_id?: string,
  member?: {
    user?: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    },
    nick?: string | null,
    roles: string[],
    joined_at: string,
    permissions: string,
    deaf: boolean,
    mute: boolean
  },
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  locale?: string,
  guild_locale?: string,
  app_permissions?: string,
  type: 2,
  data: {
    id: string,
    name: string,
    type: number,
    options?: {
      name: string,
      type: number,
      value?: string | number | boolean,
      focused?: boolean,
      options?: lazy
    }[],
    guild_id?: string,
    target_id?: string
  }
}
webhookHooks example
discord({
    webhookHooks: {
        interactions: {
            applicationCommand: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Message Component

interactions.messageComponent A user clicked a button or selected a menu option Payload
NameTypeRequiredDescription
idstringYes
application_idstringYes
tokenstringYes
version1Yes
guild_idstringNo
channel_idstringNo
memberobjectNo
userobjectNo
localestringNo
guild_localestringNo
app_permissionsstringNo
type3Yes
dataobjectYes
messageobjectYes
{
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  nick?: string | null,
  roles: string[],
  joined_at: string,
  permissions: string,
  deaf: boolean,
  mute: boolean
}
{
  id: string,
  username: string,
  discriminator: string,
  global_name?: string | null,
  avatar?: string | null,
  bot?: boolean,
  system?: boolean,
  email?: string | null,
  verified?: boolean,
  locale?: string,
  premium_type?: number,
  public_flags?: number,
  flags?: number
}
{
  custom_id: string,
  component_type: number,
  values?: string[]
}
{
  id: string,
  channel_id: string,
  content: string,
  author: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  timestamp: string,
  edited_timestamp?: string | null,
  tts: boolean,
  mention_everyone: boolean,
  mentions: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  }[],
  attachments: any[],
  embeds: {
    title?: string,
    description?: string,
    url?: string,
    color?: number,
    fields?: {
      name: string,
      value: string,
      inline?: boolean
    }[],
    footer?: {
      text: string,
      icon_url?: string
    },
    image?: {
      url: string
    },
    thumbnail?: {
      url: string
    },
    author?: {
      name: string,
      url?: string,
      icon_url?: string
    },
    timestamp?: string
  }[],
  pinned: boolean,
  type: number
}
{
  id: string,
  application_id: string,
  token: string,
  version: 1,
  guild_id?: string,
  channel_id?: string,
  member?: {
    user?: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    },
    nick?: string | null,
    roles: string[],
    joined_at: string,
    permissions: string,
    deaf: boolean,
    mute: boolean
  },
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  locale?: string,
  guild_locale?: string,
  app_permissions?: string,
  type: 3,
  data: {
    custom_id: string,
    component_type: number,
    values?: string[]
  },
  message: {
    id: string,
    channel_id: string,
    content: string,
    author: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    },
    timestamp: string,
    edited_timestamp?: string | null,
    tts: boolean,
    mention_everyone: boolean,
    mentions: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    }[],
    attachments: any[],
    embeds: {
      title?: string,
      description?: string,
      url?: string,
      color?: number,
      fields?: {
        name: string,
        value: string,
        inline?: boolean
      }[],
      footer?: {
        text: string,
        icon_url?: string
      },
      image?: {
        url: string
      },
      thumbnail?: {
        url: string
      },
      author?: {
        name: string,
        url?: string,
        icon_url?: string
      },
      timestamp?: string
    }[],
    pinned: boolean,
    type: number
  }
}
webhookHooks example
discord({
    webhookHooks: {
        interactions: {
            messageComponent: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

interactions.modalSubmit A user submitted a modal dialog Payload
NameTypeRequiredDescription
idstringYes
application_idstringYes
tokenstringYes
version1Yes
guild_idstringNo
channel_idstringNo
memberobjectNo
userobjectNo
localestringNo
guild_localestringNo
app_permissionsstringNo
type5Yes
dataobjectYes
{
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  nick?: string | null,
  roles: string[],
  joined_at: string,
  permissions: string,
  deaf: boolean,
  mute: boolean
}
{
  id: string,
  username: string,
  discriminator: string,
  global_name?: string | null,
  avatar?: string | null,
  bot?: boolean,
  system?: boolean,
  email?: string | null,
  verified?: boolean,
  locale?: string,
  premium_type?: number,
  public_flags?: number,
  flags?: number
}
{
  custom_id: string,
  components: {
    type: number,
    components: {
      type: number,
      custom_id: string,
      value: string
    }[]
  }[]
}
{
  id: string,
  application_id: string,
  token: string,
  version: 1,
  guild_id?: string,
  channel_id?: string,
  member?: {
    user?: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    },
    nick?: string | null,
    roles: string[],
    joined_at: string,
    permissions: string,
    deaf: boolean,
    mute: boolean
  },
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  locale?: string,
  guild_locale?: string,
  app_permissions?: string,
  type: 5,
  data: {
    custom_id: string,
    components: {
      type: number,
      components: {
        type: number,
        custom_id: string,
        value: string
      }[]
    }[]
  }
}
webhookHooks example
discord({
    webhookHooks: {
        interactions: {
            modalSubmit: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Ping

interactions.ping Discord sends a PING to verify the endpoint is live Payload
NameTypeRequiredDescription
idstringYes
application_idstringYes
tokenstringYes
version1Yes
guild_idstringNo
channel_idstringNo
memberobjectNo
userobjectNo
localestringNo
guild_localestringNo
app_permissionsstringNo
type1Yes
{
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  nick?: string | null,
  roles: string[],
  joined_at: string,
  permissions: string,
  deaf: boolean,
  mute: boolean
}
{
  id: string,
  username: string,
  discriminator: string,
  global_name?: string | null,
  avatar?: string | null,
  bot?: boolean,
  system?: boolean,
  email?: string | null,
  verified?: boolean,
  locale?: string,
  premium_type?: number,
  public_flags?: number,
  flags?: number
}
{
  id: string,
  application_id: string,
  token: string,
  version: 1,
  guild_id?: string,
  channel_id?: string,
  member?: {
    user?: {
      id: string,
      username: string,
      discriminator: string,
      global_name?: string | null,
      avatar?: string | null,
      bot?: boolean,
      system?: boolean,
      email?: string | null,
      verified?: boolean,
      locale?: string,
      premium_type?: number,
      public_flags?: number,
      flags?: number
    },
    nick?: string | null,
    roles: string[],
    joined_at: string,
    permissions: string,
    deaf: boolean,
    mute: boolean
  },
  user?: {
    id: string,
    username: string,
    discriminator: string,
    global_name?: string | null,
    avatar?: string | null,
    bot?: boolean,
    system?: boolean,
    email?: string | null,
    verified?: boolean,
    locale?: string,
    premium_type?: number,
    public_flags?: number,
    flags?: number
  },
  locale?: string,
  guild_locale?: string,
  app_permissions?: string,
  type: 1
}
webhookHooks example
discord({
    webhookHooks: {
        interactions: {
            ping: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})