Interface Message<C, T>

An object type of known Discord's incoming messages.

interface Message<C extends code, T extends string> {
    args: C extends "INVITE_BROWSER"
    | "GUILD_TEMPLATE_BROWSER"
        ? { code: string }
        : C extends "AUTHORIZE"
            ? {
                client_id: string;
                rpc_token?: string;
                scopes: (
                    | "applications.builds.read"
                    | "applications.builds.upload"
                    | "applications.commands.update"
                    | "applications.commands.permissions.update"
                    | "applications.entitlements"
                    | "applications.store.update"
                    | "bot"
                    | "connections"
                    | "dm_channels.read"
                    | "email"
                    | "gdm.join"
                    | "guilds"
                    | "guilds.join"
                    | "guilds.members.read"
                    | "identify"
                    | "voice"
                    | "activities.read"
                    | "messages.read"
                    | "relationships.read"
                    | "rpc.notifications.read"
                    | "rpc.voice.read"
                    | "activities.write"
                    | "rpc.voice.write"
                    | "rpc.activities.write"
                    | "webhook.incoming"
                )[];
                username?: string;
            }
            : C extends "DEEP_LINK"
                ? {
                    params: T extends "CHANNEL"
                        ? {
                            channelId?: string;
                            fingerprint: string;
                            guildId: string;
                            search: string;
                        }
                        : Record<string, unknown>;
                    type: T extends string ? T<T> : string;
                }
                : C extends "SET_ACTIVITY"
                    ? {
                        activity: {
                            application_id?: number;
                            assets?: Partial<
                                Record<
                                    "large_image"
                                    | "large_text"
                                    | "small_image"
                                    | "small_text",
                                    string,
                                >,
                            >;
                            buttons?: { label: string; url: string }[] & { length: 0 | 1 | 2 };
                            created_at: number;
                            details: string;
                            emoji?: { animated?: string; id?: number; name?: string };
                            flags?: number;
                            instance?: boolean;
                            name: string;
                            party?: {
                                id?: number;
                                size?: [current_size: number, max_size: number];
                            };
                            secrets?: Partial<Record<"join" | "spectate" | "match", string>>;
                            state?: string;
                            timestamps?: Partial<Record<"start" | "end", number>>;
                            type: RPCActivity;
                            url?: string;
                        };
                        pid: number;
                    }
                    : never;
    cmd: C;
    nonce: null
    | string;
}

Type Parameters

  • C extends code
  • T extends string

Hierarchy (View Summary)

Properties

Properties

args: C extends "INVITE_BROWSER"
| "GUILD_TEMPLATE_BROWSER"
    ? { code: string }
    : C extends "AUTHORIZE"
        ? {
            client_id: string;
            rpc_token?: string;
            scopes: (
                | "applications.builds.read"
                | "applications.builds.upload"
                | "applications.commands.update"
                | "applications.commands.permissions.update"
                | "applications.entitlements"
                | "applications.store.update"
                | "bot"
                | "connections"
                | "dm_channels.read"
                | "email"
                | "gdm.join"
                | "guilds"
                | "guilds.join"
                | "guilds.members.read"
                | "identify"
                | "voice"
                | "activities.read"
                | "messages.read"
                | "relationships.read"
                | "rpc.notifications.read"
                | "rpc.voice.read"
                | "activities.write"
                | "rpc.voice.write"
                | "rpc.activities.write"
                | "webhook.incoming"
            )[];
            username?: string;
        }
        : C extends "DEEP_LINK"
            ? {
                params: T extends "CHANNEL"
                    ? {
                        channelId?: string;
                        fingerprint: string;
                        guildId: string;
                        search: string;
                    }
                    : Record<string, unknown>;
                type: T extends string ? T<T> : string;
            }
            : C extends "SET_ACTIVITY"
                ? {
                    activity: {
                        application_id?: number;
                        assets?: Partial<
                            Record<
                                "large_image"
                                | "large_text"
                                | "small_image"
                                | "small_text",
                                string,
                            >,
                        >;
                        buttons?: { label: string; url: string }[] & { length: 0 | 1 | 2 };
                        created_at: number;
                        details: string;
                        emoji?: { animated?: string; id?: number; name?: string };
                        flags?: number;
                        instance?: boolean;
                        name: string;
                        party?: {
                            id?: number;
                            size?: [current_size: number, max_size: number];
                        };
                        secrets?: Partial<Record<"join" | "spectate" | "match", string>>;
                        state?: string;
                        timestamps?: Partial<Record<"start" | "end", number>>;
                        type: RPCActivity;
                        url?: string;
                    };
                    pid: number;
                }
                : never

Message arguments.

cmd: C

Message type/command.

nonce: null | string

Nonce identifying the communication.