Skip to content

Commit

Permalink
fix(core): adapter and database plugin should not respect filter
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 14, 2023
1 parent ee66cb9 commit d5a9dd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sleep } from '@koishijs/utils'
import { Dict } from 'cosmokit'
import { defineProperty, Dict } from 'cosmokit'
import { Bot, Fragment } from '@satorijs/core'

declare module '@satorijs/core' {
Expand All @@ -15,6 +15,9 @@ declare module '@satorijs/core' {

export * from '@satorijs/core'

// adapter plugins usually do not respect filters
defineProperty(Bot, 'filter', false)

Bot.prototype.getGuildMemberMap = async function getGuildMemberMap(this: Bot, guildId) {
const list = await this.getGuildMemberList(guildId)
return Object.fromEntries(list.map(info => [info.userId, info.nickname || info.username]))
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export { resolveConfig } from 'cordis'

export type { Disposable } from 'cordis'

declare module 'cordis' {
namespace Plugin {
interface Object {
filter?: boolean
}
}
}

declare module '@satorijs/core' {
export interface Context {
envData: EnvData
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const defineDriver = <T>(constructor: Driver.Constructor<T>, schema?: uti
name: constructor.name,
reusable: true,
Config: schema,
filter: false,
apply(ctx, config) {
config = { ...config }
prepare?.(ctx, config)
Expand Down

0 comments on commit d5a9dd5

Please sign in to comment.