Skip to content

Commit 4bd3601

Browse files
committed
feat: add activity invite command
1 parent 56b98c6 commit 4bd3601

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed

src/commands/activityInviteUser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {schemaCommandFactory} from '../utils/commandFactory';
2+
import {Command} from '../generated/schemas';
3+
4+
export const ActivityInviteUser = schemaCommandFactory(Command.ACTIVITY_INVITE_USER);

src/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {initiateImageUpload} from './initiateImageUpload';
2222
import {getChannel} from './getChannel';
2323
import {getInstanceConnectedParticipants} from './getInstanceConnectedParticipants';
2424
import {GetRelationships} from './getRelationships';
25+
import {ActivityInviteUser} from './activityInviteUser';
2526

2627
export {Commands, SetActivity};
2728

@@ -48,6 +49,7 @@ function commands(sendCommand: TSendCommand) {
4849
initiateImageUpload: initiateImageUpload(sendCommand),
4950
getInstanceConnectedParticipants: getInstanceConnectedParticipants(sendCommand),
5051
getRelationships: GetRelationships(sendCommand),
52+
activityInviteUser: ActivityInviteUser(sendCommand),
5153
};
5254
}
5355

src/generated/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,5 +346,19 @@
346346
"required": ["relationships"],
347347
"additionalProperties": false
348348
}
349+
},
350+
"ACTIVITY_INVITE_USER": {
351+
"request": {
352+
"type": "object",
353+
"properties": {
354+
"user_id": {"type": "string"},
355+
"type": {"const": 1},
356+
"content": {"type": "string", "minLength": 0, "maxLength": 1024},
357+
"pid": {"type": "number", "minimum": 0}
358+
},
359+
"required": ["user_id", "type"],
360+
"additionalProperties": false
361+
},
362+
"response": null
349363
}
350364
}

src/generated/schemas.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ export const GetRelationshipsResponseSchema = z.object({
246246
});
247247
export type GetRelationshipsResponse = zInfer<typeof GetRelationshipsResponseSchema>;
248248

249+
// ACTIVITY_INVITE_USER
250+
export const ActivityInviteUserRequestSchema = z.object({
251+
user_id: z.string(),
252+
type: z.literal(1),
253+
content: z.string().min(0).max(1024).optional(),
254+
pid: z.number().gte(0).optional(),
255+
});
256+
export type ActivityInviteUserRequest = zInfer<typeof ActivityInviteUserRequestSchema>;
257+
249258
/**
250259
* RPC Commands which support schemas.
251260
*/
@@ -257,6 +266,7 @@ export enum Command {
257266
SHARE_INTERACTION = 'SHARE_INTERACTION',
258267
SHARE_LINK = 'SHARE_LINK',
259268
GET_RELATIONSHIPS = 'GET_RELATIONSHIPS',
269+
ACTIVITY_INVITE_USER = 'ACTIVITY_INVITE_USER',
260270
}
261271

262272
const emptyResponseSchema = z.object({}).optional().nullable();
@@ -294,4 +304,8 @@ export const Schemas = {
294304
request: emptyRequestSchema,
295305
response: GetRelationshipsResponseSchema,
296306
},
307+
[Command.ACTIVITY_INVITE_USER]: {
308+
request: ActivityInviteUserRequestSchema,
309+
response: emptyResponseSchema,
310+
},
297311
} as const;

src/mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,5 @@ export const commandsMockDefault: IDiscordSDK['commands'] = {
181181
},
182182
],
183183
}),
184+
activityInviteUser: () => Promise.resolve(null),
184185
};

src/schema/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export enum Commands {
3838
GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS = 'GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS',
3939
SHARE_LINK = 'SHARE_LINK',
4040
GET_RELATIONSHIPS = 'GET_RELATIONSHIPS',
41+
ACTIVITY_INVITE_USER = 'ACTIVITY_INVITE_USER',
4142
}
4243

4344
export const ReceiveFramePayload = zod

src/schema/responses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
184184
case Commands.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS:
185185
case Commands.SHARE_LINK:
186186
case Commands.GET_RELATIONSHIPS:
187+
case Commands.ACTIVITY_INVITE_USER:
187188
const {response} = Schemas[cmd];
188189
return response.parse(data);
189190
default:

0 commit comments

Comments
 (0)