forked from pinks/eris
1
0
Fork 0

Compare commits

..

3 Commits

Author SHA1 Message Date
Akiru d266b8e342 Merge pull request 'helpCommand added' (#3) from helpCommand into main
Reviewed-on: #3
2024-01-28 11:55:48 +00:00
Akiru e45ad93229 bot/helpCommand.ts hinzugefügt
New function to send the bot description as help text.
2024-01-28 11:55:18 +00:00
Akiru ed40a902ef bot/mod.ts aktualisiert
Added new help command
Refactored code to use variables inside the bot.api.setMy... functions.
2024-01-28 11:52:54 +00:00
2 changed files with 56 additions and 12 deletions

15
bot/helpCommand.ts Normal file
View File

@ -0,0 +1,15 @@
import { ErisContext } from "./mod.ts";
import { omitUndef } from "../utils/omitUndef.ts";
import { botDescription } from "./mod.ts"; // Import the description
export async function helpCommand(ctx: ErisContext) {
await ctx.reply(
botDescription, // Send the stored description
omitUndef({
reply_to_message_id: ctx.message?.message_id,
allow_sending_without_reply: true,
disable_web_page_preview: true, // Disable link previews
parse_mode: "Markdown"
}),
);
}

View File

@ -12,6 +12,7 @@ import { img2imgCommand, img2imgQuestion } from "./img2imgCommand.ts";
import { pnginfoCommand, pnginfoQuestion } from "./pnginfoCommand.ts"; import { pnginfoCommand, pnginfoQuestion } from "./pnginfoCommand.ts";
import { queueCommand } from "./queueCommand.ts"; import { queueCommand } from "./queueCommand.ts";
import { txt2imgCommand, txt2imgQuestion } from "./txt2imgCommand.ts"; import { txt2imgCommand, txt2imgQuestion } from "./txt2imgCommand.ts";
import { helpCommand } from "./helpCommand.ts";
import { setConfig, getConfig } from "../app/config.ts"; import { setConfig, getConfig } from "../app/config.ts";
// Set the new configuration // Set the new configuration
@ -117,31 +118,57 @@ bot.use(async (ctx, next) => {
} }
}); });
// Wrap the calls in try-catch for error handling // Declare the bot description variable
async function setupBotCommands() { export const botDescription = `I can generate furry images from text.
try { \`/txt2img Nyx\`
await bot.api.setMyShortDescription("Generate furry images in '704x704', '576x832', '832x576'. https://ko-fi.com/nyxthebot https://nyx.akiru.de/");
} catch (err) {
error(`Failed to set short description: ${err.message}`);
}
try { If you want landscape or portrait:
await bot.api.setMyDescription( \`/txt2img Nyx, Size: 576x832\`
"I can generate furry images from text. If you want a different size, use 'Size: 576x832' for example." + \`/txt2img Nyx, Size: 832x576\`
"Send /txt2img to generate an image.",
);
} catch (err) {
error(`Failed to set description: ${err.message}`);
}
try { This bot uses the following model and will render nsfw and sfw:
await bot.api.setMyCommands([ \`EasyFluffV11.2.safetensors [821628644e]\`
There is no loRA support.
Please read about our terms of use:
https://nyx.akiru.de/disclaimer
You can support Nyx by sending her a coffee :3
ko-fi.com/nyxthebot`;
// Short description constant
const botShortDescription = `Generate furry images from text.
Use /help for more information.
https://ko-fi.com/nyxthebot
https://nyx.akiru.de`;
// Command descriptions
const botCommands = [
{ command: "txt2img", description: "Generate image from text" }, { command: "txt2img", description: "Generate image from text" },
{ command: "img2img", description: "Generate image from image" }, { command: "img2img", description: "Generate image from image" },
{ command: "pnginfo", description: "Try to extract prompt from raw file" }, { command: "pnginfo", description: "Try to extract prompt from raw file" },
{ command: "queue", description: "Show the current queue" }, { command: "queue", description: "Show the current queue" },
{ command: "cancel", description: "Cancel all your requests" }, { command: "cancel", description: "Cancel all your requests" },
]); { command: "help", description: "Show bot description" },
];
// Wrap the calls in try-catch for error handling
async function setupBotCommands() {
try {
await bot.api.setMyShortDescription(botShortDescription);
} catch (err) {
error(`Failed to set short description: ${err.message}`);
}
try {
await bot.api.setMyDescription(botDescription);
} catch (err) {
error(`Failed to set description: ${err.message}`);
}
try {
await bot.api.setMyCommands(botCommands);
} catch (err) { } catch (err) {
error(`Failed to set commands: ${err.message}`); error(`Failed to set commands: ${err.message}`);
} }
@ -197,6 +224,8 @@ bot.command("queue", queueCommand);
bot.command("cancel", cancelCommand); bot.command("cancel", cancelCommand);
bot.command("help", helpCommand);
bot.command("broadcast", broadcastCommand); bot.command("broadcast", broadcastCommand);
bot.command("crash", () => { bot.command("crash", () => {