diff --git a/bot/context.js b/bot/context.ts similarity index 100% rename from bot/context.js rename to bot/context.ts diff --git a/bot/index.js b/bot/index.js index d4589c1..2736414 100644 --- a/bot/index.js +++ b/bot/index.js @@ -25,4 +25,4 @@ Object.defineProperty(bot.context, "botInfo", { // cyclic dependency // bot/index requires context requires actions/warn requires bot/index -Object.assign(bot.context, require('./context')); +Object.assign(bot.context, require('./context').extn); diff --git a/tsconfig.json b/tsconfig.json index 3257cbe..201ec01 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "noEmit": true, "noImplicitAny": false, "strict": true, - "target": "ES2019" + "target": "ES2019", + "esModuleInterop": true } } diff --git a/typings/context.d.ts b/typings/context.d.ts index 1dad08f..1574d80 100644 --- a/typings/context.d.ts +++ b/typings/context.d.ts @@ -1,8 +1,4 @@ -import type { - ExtraReplyMessage, - Message, - User, -} from "telegraf/typings/telegram-types"; +import type { Convenience, Message, MessageId, User } from "telegraf/types"; import type { Context } from "telegraf"; import type { TgHtml } from "../utils/html"; @@ -10,6 +6,8 @@ interface DbUser { status: "member" | "admin" | "banned"; } +type ExtraReplyMessage = Convenience.ExtraReplyMessage; + export interface ContextExtensions { ban( this: ExtendedContext, @@ -17,6 +15,7 @@ export interface ContextExtensions { admin: User; reason: string; userToBan: User; + msg?: Message; } ): Promise; batchBan( @@ -35,24 +34,16 @@ export interface ContextExtensions { reason: string; userToWarn: User; mode: "auto" | "manual"; + msg?: Message; } ): Promise; loggedReply( this: ExtendedContext, html: TgHtml, + msg?: Message, extra?: ExtraReplyMessage ): Promise; - replyWithHTML( - this: void, - html: string | TgHtml, - extra?: ExtraReplyMessage - ): Promise; - replyWithCopy( - this: ExtendedContext, - content: Message, - options?: ExtraReplyMessage - ): Promise; } export type ExtendedContext = ContextExtensions &