From eb3950b79cdc98554f4641157f32cad71cb1c007 Mon Sep 17 00:00:00 2001 From: pinks Date: Mon, 11 Sep 2023 11:22:15 +0200 Subject: [PATCH] fix: not awaiting --- bot/txt2imgCommand.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bot/txt2imgCommand.ts b/bot/txt2imgCommand.ts index e0687fe..0ced217 100644 --- a/bot/txt2imgCommand.ts +++ b/bot/txt2imgCommand.ts @@ -18,26 +18,30 @@ export async function txt2imgCommand(ctx: Grammy.CommandContext) { async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean): Promise { if (!ctx.message?.from?.id) { - return void ctx.reply("I don't know who you are"); + await ctx.reply("I don't know who you are"); + return; } const config = ctx.session.global; if (config.pausedReason != null) { - return void ctx.reply(`I'm paused: ${config.pausedReason || "No reason given"}`); + await ctx.reply(`I'm paused: ${config.pausedReason || "No reason given"}`); + return; } const jobs = await jobStore.getBy("status.type", "waiting"); if (jobs.length >= config.maxJobs) { - return void ctx.reply( + await ctx.reply( `The queue is full. Try again later. (Max queue size: ${config.maxJobs})`, ); + return; } const userJobs = jobs.filter((job) => job.value.request.from.id === ctx.message?.from?.id); if (userJobs.length >= config.maxUserJobs) { - return void ctx.reply( + await ctx.reply( `You already have ${config.maxUserJobs} jobs in queue. Try again later.`, ); + return; } let params = parsePngInfo(match); @@ -52,11 +56,12 @@ async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean): }; } if (!params.prompt) { - return void ctx.reply( + await ctx.reply( "Please tell me what you want to see." + txt2imgQuestion.messageSuffixMarkdown(), { reply_markup: { force_reply: true, selective: true }, parse_mode: "Markdown" }, ); + return; } const replyMessage = await ctx.reply("Accepted. You are now in queue.");