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 2c3508d..96302ab 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({ @@ -83,16 +82,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(fmt(({ n }) => n`Error: cannot find this user`)) logger.error({ userId }, "UNBAN: cannot retrieve the user") - await wait(5000).then(() => msg.delete()) + await ephemeral(context.reply(fmt(({ n }) => [n`Error: cannot find this user`]))) return } diff --git a/src/commands/moderation/banall.ts b/src/commands/moderation/banall.ts index 65f2320..bad1717 100644 --- a/src/commands/moderation/banall.ts +++ b/src/commands/moderation/banall.ts @@ -12,7 +12,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/utils/messages.ts b/src/utils/messages.ts index 90c4e25..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 5 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 = 5000): Promise { +export async function ephemeral(message: MaybePromise, timeout = 20000): Promise { const msg = await Promise.resolve(message) await wait(timeout) .then(() => msg.delete())