Versions

  • v6

    4/5/2024
    Open: Version
    Changes from v5 to v6
    +1
    -1
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Method Not Allowed", { status: 405 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("GET Method Not Allowed", { status: 405 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
  • v5

    4/5/2024
    Open: Version
    Changes from v4 to v5
    +1
    -1
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Invalid Method", { status: 405 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Method Not Allowed", { status: 405 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
  • v4

    4/5/2024
    Open: Version
    Changes from v3 to v4
    +1
    -1
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Not Found", { status: 404 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Invalid Method", { status: 405 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
  • v3

    4/5/2024
    Open: Version
    Changes from v2 to v3
    +1
    -1
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Not Found", { status: 4043 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Not Found", { status: 404 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    ⦚ 29 unchanged lines ⦚
  • v2

    4/5/2024
    Open: Version
    Changes from v1 to v2
    +2
    -2
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response();
    const body = await req.json();
    const verified = await verify_discord_signature(
    Deno.env.get('discordPublicKey'),
    JSON.stringify(body),
    req.headers.get("X-Signature-Ed25519"),
    ⦚ 26 unchanged lines ⦚
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response("Not Found", { status: 4043 });
    const body = await req.json();
    const verified = await verify_discord_signature(
    Deno.env.get("discordPublicKey"),
    JSON.stringify(body),
    req.headers.get("X-Signature-Ed25519"),
    ⦚ 26 unchanged lines ⦚
  • v1

    4/5/2024
    Open: Version
    Changes from v0 to v1
    +35
    -3
    export default async function (req: Request): Promise<Response> {
    return Response.json({ ok: true })
    }
    import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";

    export const handleDiscordInteraction = async (req: Request) => {
    if (req.method === "GET") return new Response();
    const body = await req.json();
    const verified = await verify_discord_signature(
    Deno.env.get('discordPublicKey'),
    JSON.stringify(body),
    req.headers.get("X-Signature-Ed25519"),
    req.headers.get("X-Signature-Timestamp"),
    );
    if (!verified)
    return new Response("signature invalid", {
    status: 401,
    statusText: "signature invalid",
    });
    // PING
    if (body.type === 1)
    return Response.json({ type: 1 }); // PONG
    // APPLICATION_COMMAND interactions
    if (body.type === 2) {
    if (body.data?.name === "ping")
    return Response.json({
    type: 4,
    data: {
    content: `Pong! It is ${new Date()}`,
    },
    });
    return new Response("Bad request", {
    status: 400,
    statusText: "Bad request",
    });
    }
    return new Response("Not handled", { status: 422 });
    };
  • v0

    4/5/2024
    Open: Version
    +3
    -0

    export default async function (req: Request): Promise<Response> {
    return Response.json({ ok: true })
    }
1
Next
maxm-discordbotexample.web.val.run
Updated: April 5, 2024