Random duck image

This commit is contained in:
Luquinhas 2025-02-08 20:57:15 -03:00
parent f01feb7468
commit f8c54da5a2
No known key found for this signature in database
GPG key ID: D9B075FC6DC93985
4 changed files with 29 additions and 1 deletions

25
src/commands/duck.js Normal file
View file

@ -0,0 +1,25 @@
const Resources = require('../props/resources.json');
const { getStrings } = require('../plugins/checklang.js');
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
const axios = require("axios");
module.exports = (bot) => {
bot.command("duck", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
try {
const response = await axios(Resources.duckApi);
ctx.replyWithPhoto(response.data.url, {
caption: response.data.message,
reply_to_message_id: ctx.message.message_id
});
} catch (error) {
const message = Strings.duckApiErr.replace('{error}', error.message);
ctx.reply(message, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
return;
}
});
}