2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-22 09:57:50 +00:00

fix: make context.ts work

This commit is contained in:
Muthu Kumar 2023-09-19 23:45:32 +05:30
parent a5472bd928
commit 614043d711
No known key found for this signature in database
4 changed files with 9 additions and 17 deletions

View File

@ -25,4 +25,4 @@ Object.defineProperty(bot.context, "botInfo", {
// cyclic dependency // cyclic dependency
// bot/index requires context requires actions/warn requires bot/index // bot/index requires context requires actions/warn requires bot/index
Object.assign(bot.context, require('./context')); Object.assign(bot.context, require('./context').extn);

View File

@ -5,6 +5,7 @@
"noEmit": true, "noEmit": true,
"noImplicitAny": false, "noImplicitAny": false,
"strict": true, "strict": true,
"target": "ES2019" "target": "ES2019",
"esModuleInterop": true
} }
} }

21
typings/context.d.ts vendored
View File

@ -1,8 +1,4 @@
import type { import type { Convenience, Message, MessageId, User } from "telegraf/types";
ExtraReplyMessage,
Message,
User,
} from "telegraf/typings/telegram-types";
import type { Context } from "telegraf"; import type { Context } from "telegraf";
import type { TgHtml } from "../utils/html"; import type { TgHtml } from "../utils/html";
@ -10,6 +6,8 @@ interface DbUser {
status: "member" | "admin" | "banned"; status: "member" | "admin" | "banned";
} }
type ExtraReplyMessage = Convenience.ExtraReplyMessage;
export interface ContextExtensions { export interface ContextExtensions {
ban( ban(
this: ExtendedContext, this: ExtendedContext,
@ -17,6 +15,7 @@ export interface ContextExtensions {
admin: User; admin: User;
reason: string; reason: string;
userToBan: User; userToBan: User;
msg?: Message;
} }
): Promise<Message>; ): Promise<Message>;
batchBan( batchBan(
@ -35,24 +34,16 @@ export interface ContextExtensions {
reason: string; reason: string;
userToWarn: User; userToWarn: User;
mode: "auto" | "manual"; mode: "auto" | "manual";
msg?: Message;
} }
): Promise<Message>; ): Promise<Message>;
loggedReply( loggedReply(
this: ExtendedContext, this: ExtendedContext,
html: TgHtml, html: TgHtml,
msg?: Message,
extra?: ExtraReplyMessage extra?: ExtraReplyMessage
): Promise<Message>; ): Promise<Message>;
replyWithHTML(
this: void,
html: string | TgHtml,
extra?: ExtraReplyMessage
): Promise<Message>;
replyWithCopy(
this: ExtendedContext,
content: Message,
options?: ExtraReplyMessage
): Promise<Message>;
} }
export type ExtendedContext = ContextExtensions & export type ExtendedContext = ContextExtensions &