1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-21 18:21:36 +02: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 = {
afk: Boolean,
@ -47,40 +47,7 @@ export const ActivitySchema = {
export interface ActivitySchema {
afk: boolean;
status: string;
activities?: [
{
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
}
];
status: Status;
activities?: Activity[];
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 {
name: string;
type: ActivityType;
url?: string;
created_at?: Date;
name: string; // the activity's name
type: ActivityType; // 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?: {
start?: number;
end?: number;
}[];
application_id?: string;
// 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?: {
name: string;
id?: string;
amimated?: boolean;
animated: boolean;
};
party?: {
id?: string;
size?: [number, number];
size?: [number]; // used to show the party's current and maximum size // TODO: array length 2
};
assets?: {
large_image?: string;
large_text?: string;
small_image?: string;
small_text?: string;
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;
spectate?: string;
match?: string;
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?: bigint;
flags: string; // activity flags OR d together, describes what the payload includes
}
export enum ActivityType {

View File

@ -13,6 +13,7 @@ import { ConnectedAccount } from "../entities/ConnectedAccount";
import { Relationship, RelationshipType } from "../entities/Relationship";
import { Presence } from "./Presence";
import { Sticker } from "..";
import { Activity, Status } from ".";
export interface Event {
guild_id?: string;
@ -454,6 +455,37 @@ export interface RelationshipRemoveEvent extends Event {
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 =
| InvalidatedEvent
| ReadyEvent
@ -474,6 +506,7 @@ export type EventData =
| GuildMemberRemoveEvent
| GuildMemberUpdateEvent
| GuildMembersChunkEvent
| GuildMemberListUpdate
| GuildRoleCreateEvent
| GuildRoleUpdateEvent
| GuildRoleDeleteEvent
@ -523,6 +556,7 @@ export enum EVENTEnum {
GuildMemberUpdate = "GUILD_MEMBER_UPDATE",
GuildMemberSpeaking = "GUILD_MEMBER_SPEAKING",
GuildMembersChunk = "GUILD_MEMBERS_CHUNK",
GuildMemberListUpdate = "GUILD_MEMBER_LIST_UPDATE",
GuildRoleCreate = "GUILD_ROLE_CREATE",
GuildRoleDelete = "GUILD_ROLE_DELETE",
GuildRoleUpdate = "GUILD_ROLE_UPDATE",
@ -546,6 +580,7 @@ export enum EVENTEnum {
ApplicationCommandCreate = "APPLICATION_COMMAND_CREATE",
ApplicationCommandUpdate = "APPLICATION_COMMAND_UPDATE",
ApplicationCommandDelete = "APPLICATION_COMMAND_DELETE",
SessionsReplace = "SESSIONS_REPLACE",
}
export type EVENT =
@ -569,6 +604,7 @@ export type EVENT =
| "GUILD_MEMBER_UPDATE"
| "GUILD_MEMBER_SPEAKING"
| "GUILD_MEMBERS_CHUNK"
| "GUILD_MEMBER_LIST_UPDATE"
| "GUILD_ROLE_CREATE"
| "GUILD_ROLE_DELETE"
| "GUILD_ROLE_UPDATE"
@ -597,6 +633,7 @@ export type EVENT =
| "MESSAGE_ACK"
| "RELATIONSHIP_ADD"
| "RELATIONSHIP_REMOVE"
| "SESSIONS_REPLACE"
| CUSTOMEVENTS;
export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT";

View File

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