Skip to content

Commit

Permalink
log contextInstructions on bot creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Jan 11, 2024
1 parent 79c7a4a commit fe5a7eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/core/database/schema/users/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export class User {
uuid: string;

@Prop({ type: Object })
identifiers: Record<string, string>;
identifiers?: {
discordId?: string;
discordUsername?: string;
slackId?: string;
slackUsername?: string;
};

@Prop({ type: Object })
metadata: Record<string, unknown>;
Expand Down
9 changes: 4 additions & 5 deletions src/core/database/schema/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ export class UsersService {

async findOne(userDto: UserDto): Promise<User> {
let user: User;
if (userDto.identifiers && 'discordId' in userDto.identifiers) {
if ('discordID' in userDto.identifiers && userDto.identifiers.discordID) {
user = await this.userModel
.findOne({ identifiers: { discordId: userDto.identifiers.discordId } })
.findOne({ discordID: userDto.identifiers.discordID })
.exec();
}

if (userDto.identifiers && 'slackId' in userDto.identifiers) {
if ('slackID' in userDto.identifiers && userDto.identifiers.slackID) {
user = await this.userModel
.findOne({ identifiers: { slackId: userDto.identifiers.slackId } })
.findOne({ slackID: userDto.identifiers.slackID })
.exec();
}

Expand Down
12 changes: 11 additions & 1 deletion src/interfaces/discord/services/discord-thread.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ export class DiscordThreadService implements OnModuleDestroy {
});

await this._usersService.getOrCreateUser({
identifiers: { discordId: interaction.user.id },
identifiers: {
discord: {
id: interaction.user.id,
username: interaction.user.username,
},
},
});

const contextInstructions = channel.topic || '';
this._logger.log(
`Creating bot with contextInstructions: \n ''' \n ${contextInstructions}\n '''`,
);

// await this._botService.createChatbot(thread.id);
await this._botService.createBot(
thread.id,
Expand Down

0 comments on commit fe5a7eb

Please sign in to comment.