1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

added session + memberlist event

This commit is contained in:
Flam3rboy 2021-10-17 00:38:56 +02:00
parent 2b731bffee
commit bd0b941fea
5 changed files with 62 additions and 66 deletions

View File

@ -1,4 +1,4 @@
import { EmojiSchema } from "./Emoji"; import { Activity, Status } from "@fosscord/util";
export const ActivitySchema = { export const ActivitySchema = {
afk: Boolean, afk: Boolean,
@ -47,40 +47,7 @@ export const ActivitySchema = {
export interface ActivitySchema { export interface ActivitySchema {
afk: boolean; afk: boolean;
status: string; status: Status;
activities?: [ activities?: Activity[];
{
name: string; // the activity's name
type: number; // activity type // TODO: check if its between range 0-5
url?: string; // stream url, is validated when type is 1
created_at?: number; // unix timestamp of when the activity was added to the user's session
timestamps?: {
// unix timestamps for start and/or end of the game
start: number;
end: number;
};
application_id?: string; // application id for the game
details?: string;
state?: string;
emoji?: EmojiSchema;
party?: {
id?: string;
size?: [number]; // used to show the party's current and maximum size // TODO: array length 2
};
assets?: {
large_image?: string; // the id for a large asset of the activity, usually a snowflake
large_text?: string; // text displayed when hovering over the large image of the activity
small_image?: string; // the id for a small asset of the activity, usually a snowflake
small_text?: string; // text displayed when hovering over the small image of the activity
};
secrets?: {
join?: string; // the secret for joining a party
spectate?: string; // the secret for spectating a game
match?: string; // the secret for a specific instanced match
};
instance?: boolean;
flags: string; // activity flags OR d together, describes what the payload includes
}
];
since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle
} }

View File

@ -1,11 +0,0 @@
export const EmojiSchema = {
name: String, // the name of the emoji
$id: String, // the id of the emoji
animated: Boolean, // whether this emoji is animated
};
export interface EmojiSchema {
name: string;
id?: string;
animated: Boolean;
}

View File

@ -1,37 +1,38 @@
export interface Activity { export interface Activity {
name: string; name: string; // the activity's name
type: ActivityType; type: ActivityType; // activity type // TODO: check if its between range 0-5
url?: string; url?: string; // stream url, is validated when type is 1
created_at?: Date; created_at?: number; // unix timestamp of when the activity was added to the user's session
timestamps?: { timestamps?: {
start?: number; // unix timestamps for start and/or end of the game
end?: number; start: number;
}[]; end: number;
application_id?: string; };
application_id?: string; // application id for the game
details?: string; details?: string;
state?: string; state?: string;
emoji?: { emoji?: {
name: string; name: string;
id?: string; id?: string;
amimated?: boolean; animated: boolean;
}; };
party?: { party?: {
id?: string; id?: string;
size?: [number, number]; size?: [number]; // used to show the party's current and maximum size // TODO: array length 2
}; };
assets?: { assets?: {
large_image?: string; large_image?: string; // the id for a large asset of the activity, usually a snowflake
large_text?: string; large_text?: string; // text displayed when hovering over the large image of the activity
small_image?: string; small_image?: string; // the id for a small asset of the activity, usually a snowflake
small_text?: string; small_text?: string; // text displayed when hovering over the small image of the activity
}; };
secrets?: { secrets?: {
join?: string; join?: string; // the secret for joining a party
spectate?: string; spectate?: string; // the secret for spectating a game
match?: string; match?: string; // the secret for a specific instanced match
}; };
instance?: boolean; instance?: boolean;
flags?: bigint; flags: string; // activity flags OR d together, describes what the payload includes
} }
export enum ActivityType { export enum ActivityType {

View File

@ -13,6 +13,7 @@ import { ConnectedAccount } from "../entities/ConnectedAccount";
import { Relationship, RelationshipType } from "../entities/Relationship"; import { Relationship, RelationshipType } from "../entities/Relationship";
import { Presence } from "./Presence"; import { Presence } from "./Presence";
import { Sticker } from ".."; import { Sticker } from "..";
import { Activity, Status } from ".";
export interface Event { export interface Event {
guild_id?: string; guild_id?: string;
@ -454,6 +455,37 @@ export interface RelationshipRemoveEvent extends Event {
data: Omit<PublicRelationship, "nickname">; data: Omit<PublicRelationship, "nickname">;
} }
export interface SessionsReplace extends Event {
event: "SESSIONS_REPLACE";
data: {
activities: Activity[];
client_info: {
version: number;
os: string;
client: string;
};
status: Status;
}[];
}
export interface GuildMemberListUpdate extends Event {
event: "GUILD_MEMBER_LIST_UPDATE";
data: {
groups: { id: string; count: number }[];
guild_id: string;
id: string;
member_count: number;
online_count: number;
ops: {
index: number;
item: {
member?: PublicMember & { presence: Presence };
group?: { id: string; count: number }[];
};
}[];
};
}
export type EventData = export type EventData =
| InvalidatedEvent | InvalidatedEvent
| ReadyEvent | ReadyEvent
@ -474,6 +506,7 @@ export type EventData =
| GuildMemberRemoveEvent | GuildMemberRemoveEvent
| GuildMemberUpdateEvent | GuildMemberUpdateEvent
| GuildMembersChunkEvent | GuildMembersChunkEvent
| GuildMemberListUpdate
| GuildRoleCreateEvent | GuildRoleCreateEvent
| GuildRoleUpdateEvent | GuildRoleUpdateEvent
| GuildRoleDeleteEvent | GuildRoleDeleteEvent
@ -523,6 +556,7 @@ export enum EVENTEnum {
GuildMemberUpdate = "GUILD_MEMBER_UPDATE", GuildMemberUpdate = "GUILD_MEMBER_UPDATE",
GuildMemberSpeaking = "GUILD_MEMBER_SPEAKING", GuildMemberSpeaking = "GUILD_MEMBER_SPEAKING",
GuildMembersChunk = "GUILD_MEMBERS_CHUNK", GuildMembersChunk = "GUILD_MEMBERS_CHUNK",
GuildMemberListUpdate = "GUILD_MEMBER_LIST_UPDATE",
GuildRoleCreate = "GUILD_ROLE_CREATE", GuildRoleCreate = "GUILD_ROLE_CREATE",
GuildRoleDelete = "GUILD_ROLE_DELETE", GuildRoleDelete = "GUILD_ROLE_DELETE",
GuildRoleUpdate = "GUILD_ROLE_UPDATE", GuildRoleUpdate = "GUILD_ROLE_UPDATE",
@ -546,6 +580,7 @@ export enum EVENTEnum {
ApplicationCommandCreate = "APPLICATION_COMMAND_CREATE", ApplicationCommandCreate = "APPLICATION_COMMAND_CREATE",
ApplicationCommandUpdate = "APPLICATION_COMMAND_UPDATE", ApplicationCommandUpdate = "APPLICATION_COMMAND_UPDATE",
ApplicationCommandDelete = "APPLICATION_COMMAND_DELETE", ApplicationCommandDelete = "APPLICATION_COMMAND_DELETE",
SessionsReplace = "SESSIONS_REPLACE",
} }
export type EVENT = export type EVENT =
@ -569,6 +604,7 @@ export type EVENT =
| "GUILD_MEMBER_UPDATE" | "GUILD_MEMBER_UPDATE"
| "GUILD_MEMBER_SPEAKING" | "GUILD_MEMBER_SPEAKING"
| "GUILD_MEMBERS_CHUNK" | "GUILD_MEMBERS_CHUNK"
| "GUILD_MEMBER_LIST_UPDATE"
| "GUILD_ROLE_CREATE" | "GUILD_ROLE_CREATE"
| "GUILD_ROLE_DELETE" | "GUILD_ROLE_DELETE"
| "GUILD_ROLE_UPDATE" | "GUILD_ROLE_UPDATE"
@ -597,6 +633,7 @@ export type EVENT =
| "MESSAGE_ACK" | "MESSAGE_ACK"
| "RELATIONSHIP_ADD" | "RELATIONSHIP_ADD"
| "RELATIONSHIP_REMOVE" | "RELATIONSHIP_REMOVE"
| "SESSIONS_REPLACE"
| CUSTOMEVENTS; | CUSTOMEVENTS;
export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT"; export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT";

View File

@ -1,10 +1,12 @@
import { ClientStatus, Status } from "./Status"; import { ClientStatus, Status } from "./Status";
import { Activity } from "./Activity"; import { Activity } from "./Activity";
import { PublicUser } from "../entities/User";
export interface Presence { export interface Presence {
user_id: string; user: PublicUser;
guild_id?: string; guild_id?: string;
status: Status; status: Status;
activities: Activity[]; activities: Activity[];
client_status: ClientStatus; client_status: ClientStatus;
// TODO: game
} }