Skip to content

Commit

Permalink
feat: allow setting activity type (#15)
Browse files Browse the repository at this point in the history
* feat: allow setting activity type

* fix: deno fmt
  • Loading branch information
NextFire authored Oct 9, 2024
1 parent c68f9dd commit e6f9355
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DiscordIPC, PacketIPCEvent } from "./conn.ts";
import type {
Activity,
ActivityType,
ApplicationPayload,
AuthenticateResponsePayload,
ChannelPayload,
Expand Down Expand Up @@ -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() {
Expand All @@ -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",
{
Expand Down
10 changes: 10 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// deno-lint-ignore-file camelcase

export interface Activity {
type?: ActivityType;
details?: string;
state?: string;
assets?: {
Expand Down Expand Up @@ -28,6 +29,15 @@ export interface Activity {
}[];
}

export enum ActivityType {
PLAYING,
STREAMING,
LISTENING,
WATCHING,
CUSTOM,
COMPETING,
}

export enum OpCode {
HANDSHAKE,
FRAME,
Expand Down

0 comments on commit e6f9355

Please sign in to comment.