From e6f9355bcf87e7312e71d25b8aaff32be8cc9335 Mon Sep 17 00:00:00 2001 From: Nam Vu Date: Wed, 9 Oct 2024 18:32:31 +0200 Subject: [PATCH] feat: allow setting activity type (#15) * feat: allow setting activity type * fix: deno fmt --- src/client.ts | 7 +++++-- src/types.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index 0f66402..9fb6b2f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { DiscordIPC, PacketIPCEvent } from "./conn.ts"; import type { Activity, + ActivityType, ApplicationPayload, AuthenticateResponsePayload, ChannelPayload, @@ -72,7 +73,9 @@ export class Client { get userTag() { return this.user === undefined ? undefined - : `${this.user.username}${this.user.discriminator === "0" ? "" : `#${this.user.discriminator}`}`; + : `${this.user.username}${ + this.user.discriminator === "0" ? "" : `#${this.user.discriminator}` + }`; } get authenticated() { @@ -95,7 +98,7 @@ export class Client { */ setActivity(activity?: Activity) { return this.ipc!.sendCommand< - Activity & { application_id: string; type: number } + Activity & { application_id: string; type: ActivityType } >( "SET_ACTIVITY", { diff --git a/src/types.ts b/src/types.ts index 77e7c64..2d99d96 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,7 @@ // deno-lint-ignore-file camelcase export interface Activity { + type?: ActivityType; details?: string; state?: string; assets?: { @@ -28,6 +29,15 @@ export interface Activity { }[]; } +export enum ActivityType { + PLAYING, + STREAMING, + LISTENING, + WATCHING, + CUSTOM, + COMPETING, +} + export enum OpCode { HANDSHAKE, FRAME,