mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-22 18:08:51 +00:00
Fix some TypeScript errors
This commit is contained in:
parent
e6c60a4a20
commit
e60d2e31fb
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const dedent = require('dedent-js');
|
const dedent = require('dedent-js');
|
||||||
@ -26,6 +27,7 @@ module.exports = async ({ admin, amend, reason, userToWarn }) => {
|
|||||||
{ amend }
|
{ amend }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
const recentWarns = warns.filter(isNewerThan(date - ms(expireWarnsAfter)));
|
const recentWarns = warns.filter(isNewerThan(date - ms(expireWarnsAfter)));
|
||||||
|
|
||||||
const count = {
|
const count = {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** @type {import('telegraf/typings/telegram-types').ExtraReplyMessage} */
|
||||||
const replyOptions = {
|
const replyOptions = {
|
||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
parse_mode: 'HTML',
|
parse_mode: 'HTML',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// "clone" the function (https://stackoverflow.com/a/6772648)
|
module.exports = require('./help');
|
||||||
module.exports = require('./help').bind();
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Composer } = require('telegraf');
|
const { Composer } = require('telegraf');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../../typings/context').ExtendedContext} ExtendedContext
|
||||||
|
* @type {import('telegraf').Composer<ExtendedContext>}
|
||||||
|
*/
|
||||||
const composer = new Composer();
|
const composer = new Composer();
|
||||||
|
|
||||||
const { deleteAfter } = require('../../utils/tg');
|
const { deleteAfter } = require('../../utils/tg');
|
||||||
|
11
utils/log.js
11
utils/log.js
@ -1,21 +1,12 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
const { inspect } = require('util');
|
const { inspect } = require('util');
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Error} err
|
|
||||||
* Logs errors to console
|
|
||||||
* @returns {undefined}
|
|
||||||
*/
|
|
||||||
const logError = err => console.error(err);
|
const logError = err => console.error(err);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Object} value
|
|
||||||
* Echos the value of a value.
|
|
||||||
* @returns {undefined}
|
|
||||||
*/
|
|
||||||
const print = value =>
|
const print = value =>
|
||||||
console.log(inspect(value, { colors: true, depth: null }));
|
console.log(inspect(value, { colors: true, depth: null }));
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const XRegExp = require('xregexp');
|
const XRegExp = require('xregexp');
|
||||||
@ -21,6 +22,7 @@ const botReply = ({ from, entities = [] }) => {
|
|||||||
|
|
||||||
const flagsRegex = /\s+(?:--?|—)(\w+)(?:=(\S*))?/g;
|
const flagsRegex = /\s+(?:--?|—)(\w+)(?:=(\S*))?/g;
|
||||||
|
|
||||||
|
/** @returns {Generator<[string, string | undefined]>} */
|
||||||
function *extractFlags(flagS) {
|
function *extractFlags(flagS) {
|
||||||
for (const [ , name, value ] of flagS.matchAll(flagsRegex)) {
|
for (const [ , name, value ] of flagS.matchAll(flagsRegex)) {
|
||||||
yield [ name.toLowerCase(), value ];
|
yield [ name.toLowerCase(), value ];
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const millisecond = require('millisecond');
|
const millisecond = require('millisecond');
|
||||||
@ -40,11 +41,7 @@ const displayUser = user =>
|
|||||||
? link(user)
|
? link(user)
|
||||||
: html`an user with id <code>${user.id}</code>`;
|
: html`an user with id <code>${user.id}</code>`;
|
||||||
|
|
||||||
/**
|
/** @param {number | string | false} ms */
|
||||||
* @param {number} ms
|
|
||||||
* Deletes messages after (ms) milliseconds
|
|
||||||
* @returns {undefined}
|
|
||||||
*/
|
|
||||||
const deleteAfter = ms => (ctx, next) => {
|
const deleteAfter = ms => (ctx, next) => {
|
||||||
if (ms !== false) {
|
if (ms !== false) {
|
||||||
setTimeout(ctx.deleteMessage, millisecond(ms));
|
setTimeout(ctx.deleteMessage, millisecond(ms));
|
||||||
@ -52,6 +49,7 @@ const deleteAfter = ms => (ctx, next) => {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @param {number | string | false} ms */
|
||||||
const scheduleDeletion = (ms = 5 * 60 * 1000) => message => {
|
const scheduleDeletion = (ms = 5 * 60 * 1000) => message => {
|
||||||
const { chat, message_id } = message;
|
const { chat, message_id } = message;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user