forked from pinks/eris
fix: not awaiting
This commit is contained in:
parent
3984ca337c
commit
eb3950b79c
|
@ -18,26 +18,30 @@ export async function txt2imgCommand(ctx: Grammy.CommandContext<Context>) {
|
||||||
|
|
||||||
async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean): Promise<void> {
|
async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean): Promise<void> {
|
||||||
if (!ctx.message?.from?.id) {
|
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;
|
const config = ctx.session.global;
|
||||||
if (config.pausedReason != null) {
|
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");
|
const jobs = await jobStore.getBy("status.type", "waiting");
|
||||||
if (jobs.length >= config.maxJobs) {
|
if (jobs.length >= config.maxJobs) {
|
||||||
return void ctx.reply(
|
await ctx.reply(
|
||||||
`The queue is full. Try again later. (Max queue size: ${config.maxJobs})`,
|
`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);
|
const userJobs = jobs.filter((job) => job.value.request.from.id === ctx.message?.from?.id);
|
||||||
if (userJobs.length >= config.maxUserJobs) {
|
if (userJobs.length >= config.maxUserJobs) {
|
||||||
return void ctx.reply(
|
await ctx.reply(
|
||||||
`You already have ${config.maxUserJobs} jobs in queue. Try again later.`,
|
`You already have ${config.maxUserJobs} jobs in queue. Try again later.`,
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = parsePngInfo(match);
|
let params = parsePngInfo(match);
|
||||||
|
@ -52,11 +56,12 @@ async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean):
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!params.prompt) {
|
if (!params.prompt) {
|
||||||
return void ctx.reply(
|
await ctx.reply(
|
||||||
"Please tell me what you want to see." +
|
"Please tell me what you want to see." +
|
||||||
txt2imgQuestion.messageSuffixMarkdown(),
|
txt2imgQuestion.messageSuffixMarkdown(),
|
||||||
{ reply_markup: { force_reply: true, selective: true }, parse_mode: "Markdown" },
|
{ reply_markup: { force_reply: true, selective: true }, parse_mode: "Markdown" },
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const replyMessage = await ctx.reply("Accepted. You are now in queue.");
|
const replyMessage = await ctx.reply("Accepted. You are now in queue.");
|
||||||
|
|
Loading…
Reference in New Issue