Skip to content

Commit

Permalink
feat: add password option to start command
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkiir committed Feb 22, 2023
1 parent d4dd89a commit b16cc97
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions bot/classes/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 42,7 @@ export class BotRoom extends Room<RoomState> {
this.setPatchRate(40);
this.setPrivate(true);
this.state.ownerId = options.ownerId;
this.state.password = options.password;
await this.registerMessageHandlers();
await startSession({ room: this, options });
}
Expand Down
3 changes: 3 additions & 0 deletions bot/classes/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,7 @@ export type StartSessionOptions = VMRequestBody & {
url?: string;
ownerId: string;
existingSession?: BotRoom["session"] & { members?: User[] };
password?: string;
};

type BaseContext = { room: BotRoom };
Expand Down Expand Up @@ -120,6 121,7 @@ export async function startSession(ctx: BaseContext & { options: StartSessionOpt
sessionId: hbSession.sessionId,
adminToken: hbSession.adminToken,
ownerId: ctx.options.ownerId,
password: ctx.options.password,
createdAt: new Date(),
url: ctx.room.roomId,
region: ctx.options.region,
Expand Down Expand Up @@ -307,6 309,7 @@ export async function restartActiveSessions(): Promise<Session[]> {
ownerId: session.ownerId,
region: session.region,
existingSession: session,
password: session.password,
} as StartSessionOptions)
.then(() => restartedSessions.push(session))
.catch(() => {});
Expand Down
6 changes: 6 additions & 0 deletions bot/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 33,11 @@ export default class Start extends SlashCommand<BotClient> {
name: "extra",
description: "Extra options 👀",
},
{
type: CommandOptionType.STRING,
name: "password",
description: "Password to protect the session",
},
],
});
}
Expand All @@ -44,6 49,7 @@ export default class Start extends SlashCommand<BotClient> {
region: ctx.options.region || "NA",
ownerId: ctx.user.id,
start_url: ctx.options.website,
password: ctx.options.password,
} as StartSessionOptions;

const extraOptions = ctx.options.extra?.split(" ") ?? [];
Expand Down
2 changes: 2 additions & 0 deletions bot/prisma/migrations/20230222183204_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 1,2 @@
-- AlterTable
ALTER TABLE "Session" ADD COLUMN "password" TEXT;
1 change: 1 addition & 0 deletions bot/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 39,5 @@ model Session {
guildId String? // discord guild id
messageId String? // discord message id
feedback String? // feedback from the user
password String? // password for the session
}
2 changes: 2 additions & 0 deletions bot/schemas/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,8 @@ export class RoomState extends Schema {
@type("string") embedUrl?: string;
@type("string") sessionId?: string;
@type("string") ownerId: string;
// Not synced
password?: string;
}

export default RoomState;
2 changes: 2 additions & 0 deletions client/src/schemas/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,8 @@ export class RoomState extends Schema {
@type("string") embedUrl?: string;
@type("string") sessionId?: string;
@type("string") ownerId: string;
// Not synced
password?: string;
}

export default RoomState;
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 6,8 @@

Whether its studies, games, anime or more, the Hyperbeam Discord bot lets you enjoy the web together. With a full shared virtual browser at your fingertips, you can open any website and share the link with your friends for a quick and simple co-browsing experience.

|[Add to server][InviteLink]|[Get support][Support]|
|---|---|
| [Add to server][invitelink] | [Get support][support] |
| --------------------------- | ---------------------- |

## Features

Expand Down Expand Up @@ -92,5 92,5 @@ Whether its studies, games, anime or more, the Hyperbeam Discord bot lets you en
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Prisma](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma)

[InviteLink]:<https://discord.com/api/oauth2/authorize?client_id=983910226489126932&redirect_uri=https://bot.hyperbeam.com/authorize&response_type=code&scope=identify email bot applications.commands&permissions=277062470720>
[Support]:<https://discord.gg/D78RsGfQjq>
[invitelink]: https://discord.com/api/oauth2/authorize?client_id=983910226489126932&redirect_uri=https://bot.hyperbeam.com/authorize&response_type=code&scope=identify email bot applications.commands&permissions=277062470720
[support]: https://discord.gg/D78RsGfQjq

0 comments on commit b16cc97

Please sign in to comment.