Skip to content

Commit

Permalink
refactor: Update rmbg.js and sticker.js to improve reply validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj-x0 committed May 15, 2024
1 parent 70dd0fd commit 939ebbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/plugins/rmbg.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ command(
"Set RemoveBg API Key in config.js \n Get it from https://www.remove.bg/api"
);
if (!message.reply_message && !message.reply_message.image)

return await message.reply("Reply to an image");
let buff = await m.quoted.download();
let buffer = await removeBg(buff);
Expand Down
15 changes: 7 additions & 8 deletions assets/plugins/sticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ command(
type: "converter",
},
async (message, match, m) => {
if (
!(
message.reply_message.video ||
message.reply_message.image ||
message.reply_message.text
)
)
return await message.reply("_Reply to photo/video/text_");
const isValid =
message.reply_message.video ||
message.reply_message.image ||
message.reply_message.text ||
message.reply_message.mimetype.includes("image");

if (isValid) return await message.reply("_Reply to photo/video/text_");
if (message.reply_message.text) {
let buff = await textToImg(message.reply_message.text);
return await message.sendMessage(
Expand Down
4 changes: 4 additions & 0 deletions lib/Messages/ReplyMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class ReplyMessage extends Base {
const audioMessage = quotedMessage.audioMessage;
this.audio = audioMessage;
this.mimetype = audioMessage.mimetype;
} else if (quotedMessage.documentMessage) {
const documentMessage = quotedMessage.documentMessage;
this.document = documentMessage;
this.mimetype = documentMessage.mimetype;
}
}

Expand Down

0 comments on commit 939ebbe

Please sign in to comment.