Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/commands/management/grants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -253,8 +252,6 @@ export const grants = new CommandsCollection<Role>("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()
})

Expand Down
7 changes: 2 additions & 5 deletions src/commands/moderation/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Role>("Banning")
.createCommand({
Expand Down Expand Up @@ -83,16 +82,14 @@ export const ban = new CommandsCollection<Role>("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
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/moderation/banall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BYPASS_ROLES: Role[] = ["president", "owner", "direttivo"]
export const banAll = new CommandsCollection<Role>("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"],
Expand Down
4 changes: 2 additions & 2 deletions src/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessageXFragment>, timeout = 5000): Promise<void> {
export async function ephemeral(message: MaybePromise<MessageXFragment>, timeout = 20000): Promise<void> {
const msg = await Promise.resolve(message)
await wait(timeout)
.then(() => msg.delete())
Expand Down
Loading