We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
grammy-guard
1 parent 8d4f1d2 commit 6a83982Copy full SHA for 6a83982
src/bot/features/admin.ts
@@ -7,7 +7,9 @@ import { Composer } from 'grammy'
7
8
const composer = new Composer<Context>()
9
10
-const feature = composer.chatType('private').filter(ctx => isAdmin(ctx.config.botAdmins)(ctx))
+const feature = composer
11
+ .chatType('private')
12
+ .filter(isAdmin)
13
14
feature.command(
15
'setcommands',
src/bot/filters/is-admin.ts
@@ -1,3 +1,5 @@
1
-import { isUserHasId } from 'grammy-guard'
+import type { Context } from '#root/bot/context.js'
2
3
-export const isAdmin = (ids: number[]) => isUserHasId(...ids)
+export function isAdmin(ctx: Context) {
4
+ return !!ctx.from && ctx.config.botAdmins.includes(ctx.from.id)
5
+}
0 commit comments