Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): warn when broadcast with channels but not found #1349

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/core/src/database.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as utils from '@koishijs/utils'
import { defineProperty, Dict, MaybeArray } from 'cosmokit'
import { Database, Driver, Update } from '@minatojs/core'
import { Fragment, Schema, Universal } from '@satorijs/core'
import { Fragment, Logger, Schema, Universal } from '@satorijs/core'
import { Context, Plugin } from './context'

const logger = new Logger('database')

declare module './context' {
interface Events {
'model'(name: keyof Tables): void
Expand Down Expand Up @@ -198,7 +200,12 @@

return (await Promise.all(this.app.bots.map((bot) => {
const targets = assignMap[bot.platform]?.[bot.selfId]
if (!targets) return Promise.resolve([])
if (!targets) {
if (channels) logger.warn(

Check failure on line 204 in packages/core/src/database.ts

View workflow job for this annotation

GitHub Actions / lint

Expected { after 'if' condition

Check failure on line 204 in packages/core/src/database.ts

View workflow job for this annotation

GitHub Actions / lint

Expected { after 'if' condition
`no channel found for ${channels}, see https://koishi.chat/api/core/context.html#ctx-broadcast for more details.`

Check failure on line 205 in packages/core/src/database.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma

Check failure on line 205 in packages/core/src/database.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)
return Promise.resolve([])
}

Check warning on line 208 in packages/core/src/database.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/database.ts#L204-L208

Added lines #L204 - L208 were not covered by tests
const sessions = targets.map(({ id, guildId, locales }) => {
const session = bot.session({
type: 'message',
Expand Down
Loading