From 36b88476fd33597c9b342418dd4076f760c4b6f1 Mon Sep 17 00:00:00 2001 From: Tommaso Morganti Date: Fri, 10 Apr 2026 17:40:28 +0200 Subject: [PATCH 1/3] fix: ephemeral messages default time, typo --- src/commands/management/grants.ts | 3 --- src/commands/moderation/ban.ts | 7 ++----- src/commands/moderation/banall.ts | 2 +- src/commands/moderation/mute.ts | 1 - src/utils/messages.ts | 4 ++-- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/commands/management/grants.ts b/src/commands/management/grants.ts index a694c00..545b1ab 100644 --- a/src/commands/management/grants.ts +++ b/src/commands/management/grants.ts @@ -9,7 +9,6 @@ import { duration } from "@/utils/duration" import { fmt, fmtUser } from "@/utils/format" import { getTelegramId } from "@/utils/telegram-id" import { numberOrString, type Role } from "@/utils/types" -import { wait } from "@/utils/wait" const dateFormat = new Intl.DateTimeFormat(undefined, { dateStyle: "medium", @@ -253,8 +252,6 @@ export const grants = new CommandsCollection("Grants").createCommand({ .text("❌ Cancel", async (ctx) => { await ctx.editMessageText(fmt(({ b, skip }) => [skip`${baseMsg()}`, b`❌ Grant Cancelled`], { sep: "\n\n" })) ctx.menu.close() - await wait(5000) - await ctx.deleteMessage().catch(() => {}) await conversation.halt() }) diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index f75f9b8..b9ddd48 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -7,7 +7,6 @@ import { ephemeral } from "@/utils/messages" import { getTelegramId } from "@/utils/telegram-id" import { numberOrString, type Role } from "@/utils/types" import { getUser } from "@/utils/users" -import { wait } from "@/utils/wait" export const ban = new CommandsCollection("Banning") .createCommand({ @@ -80,16 +79,14 @@ export const ban = new CommandsCollection("Banning") if (!userId) { logger.debug(`unban: no userId for username ${args.username}`) - const msg = await context.reply(fmt(({ b }) => b`@${context.from.username} user not found`)) - await wait(5000).then(() => msg.delete()) + await ephemeral(context.reply(fmt(({ b }) => b`@${context.from.username} user not found`))) return } const user = await getUser(userId, context) if (!user) { - const msg = await context.reply("Error: cannot find this user") logger.error({ userId }, "UNBAN: cannot retrieve the user") - await wait(5000).then(() => msg.delete()) + await ephemeral(context.reply("Error: cannot find this user")) return } diff --git a/src/commands/moderation/banall.ts b/src/commands/moderation/banall.ts index 2f87543..8934eec 100644 --- a/src/commands/moderation/banall.ts +++ b/src/commands/moderation/banall.ts @@ -11,7 +11,7 @@ const BYPASS_ROLES: Role[] = ["president", "owner", "direttivo"] export const banAll = new CommandsCollection("Ban All") .createCommand({ trigger: "ban_all", - description: "PREMA BAN a user from all the Network's groups", + description: "PERMA BAN a user from all the Network's groups", scope: "private", permissions: { allowedRoles: ["owner", "direttivo"], diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index c48b124..219639e 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -7,7 +7,6 @@ import { ephemeral } from "@/utils/messages" import { getTelegramId } from "@/utils/telegram-id" import { numberOrString, type Role } from "@/utils/types" import { getUser } from "@/utils/users" -import { wait } from "@/utils/wait" export const mute = new CommandsCollection("Muting") .createCommand({ diff --git a/src/utils/messages.ts b/src/utils/messages.ts index 90c4e25..63fd939 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -44,10 +44,10 @@ export function createFakeMessage(chatId: number, messageId: number, from: User, * so it can be used without awaiting it. * * @param message The message to delete or its promise - * @param timeout Timeout in ms, defaults to 5 seconds + * @param timeout Timeout in ms, defaults to 30 seconds * @returns a void promise that resolves after the message is deleted (or if the deletion fails) */ -export async function ephemeral(message: MaybePromise, timeout = 5000): Promise { +export async function ephemeral(message: MaybePromise, timeout = 30000): Promise { const msg = await Promise.resolve(message) await wait(timeout) .then(() => msg.delete()) From 0aa416096b4d6c2f9ed3d592c9ae3b2434f6161a Mon Sep 17 00:00:00 2001 From: Tommaso Morganti Date: Fri, 10 Apr 2026 20:53:41 +0200 Subject: [PATCH 2/3] fix: merge sono stupido --- src/commands/moderation/ban.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 3098304..5ed7f2c 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -88,10 +88,6 @@ export const ban = new CommandsCollection("Banning") const user = await getUser(userId, context) if (!user) { -<<<<<<< fix-ephemeral -======= - const msg = await context.reply(fmt(({ n }) => n`Error: cannot find this user`)) ->>>>>>> main logger.error({ userId }, "UNBAN: cannot retrieve the user") await ephemeral(context.reply("Error: cannot find this user")) return From e3dfec72e5b9fedbe7188da29c3aed3565685bf7 Mon Sep 17 00:00:00 2001 From: Tommaso Morganti Date: Sat, 11 Apr 2026 15:53:37 +0200 Subject: [PATCH 3/3] fix: stuff --- src/commands/moderation/ban.ts | 2 +- src/utils/messages.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 5ed7f2c..96302ab 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -89,7 +89,7 @@ export const ban = new CommandsCollection("Banning") const user = await getUser(userId, context) if (!user) { logger.error({ userId }, "UNBAN: cannot retrieve the user") - await ephemeral(context.reply("Error: cannot find this user")) + await ephemeral(context.reply(fmt(({ n }) => [n`Error: cannot find this user`]))) return } diff --git a/src/utils/messages.ts b/src/utils/messages.ts index 63fd939..e90b8e9 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -44,10 +44,10 @@ export function createFakeMessage(chatId: number, messageId: number, from: User, * so it can be used without awaiting it. * * @param message The message to delete or its promise - * @param timeout Timeout in ms, defaults to 30 seconds + * @param timeout Timeout in ms, defaults to 20 seconds * @returns a void promise that resolves after the message is deleted (or if the deletion fails) */ -export async function ephemeral(message: MaybePromise, timeout = 30000): Promise { +export async function ephemeral(message: MaybePromise, timeout = 20000): Promise { const msg = await Promise.resolve(message) await wait(timeout) .then(() => msg.delete())