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
// 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,
"noImplicitAny": false,
"strict": true,
"target": "ES2019"
"target": "ES2019",
"esModuleInterop": true
}
}

21
typings/context.d.ts vendored
View File

@ -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<Message>;
batchBan(
@ -35,24 +34,16 @@ export interface ContextExtensions {
reason: string;
userToWarn: User;
mode: "auto" | "manual";
msg?: Message;
}
): Promise<Message>;
loggedReply(
this: ExtendedContext,
html: TgHtml,
msg?: Message,
extra?: ExtraReplyMessage
): 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 &