Skip to content

Commit

Permalink
fix(satori): ensure message.content in json format
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 25, 2024
1 parent 945b34e commit 2a3be18
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/core/src/session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Channel, Event, GuildMember, Login, Message, User } from '@satorijs/protocol'
import { defineProperty, isNullable } from 'cosmokit'
import { clone, defineProperty, isNullable } from 'cosmokit'
import { Context, Service } from 'cordis'
import { Bot } from './bot'
import h from '@satorijs/element'
Expand Down Expand Up @@ -138,15 +138,20 @@ export class Session<C extends Context = Context> {
}, this)
}

toJSON(): Event {
return {
toJSON() {
const event: Event = {
login: {
platform: this.platform,
user: { id: this.selfId },
} as Login,
...this.event,
...clone(this.event),
id: this.id,
}
if (event.message?.elements) {
event.message.content = this.content
delete event.message.elements
}
return event
}
}

Expand Down

0 comments on commit 2a3be18

Please sign in to comment.