goat
command
rip
No description
0
views
0
likes
0
installs
raw source
const axios = require("axios");
const fs = require("fs");
const path = require("path");
const mahmud = async () => {
const base = await axios.get(
"https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"
);
return base.data.mahmud;
};
module.exports = {
config: {
name: "rip",
version: "2.7",
author: "ASIF",
countDown: 10,
role: 0,
description: {
en: "Give someone a rip effect",
vi: "Tạo hiệu ứng rip cho ai đó"
},
category: "fun",
guide: {
en: " {pn} <@tag>: Give rip effect by tagging"
+ "\n {pn} <uid>: Create effect using UID"
+ "\n (Or use by replying to a message)",
vi: " {pn} <@tag>: Tạo hiệu ứng rip bằng cách gắn thẻ"
+ "\n {pn} <uid>: Tạo hiệu ứng bằng UID"
+ "\n (Hoặc phản hồi tin nhắn)"
}
},
langs: {
en: {
noTarget:
"× Baby, mention, reply, or provide UID of the target.",
success:
"Baby, it’s just for fun. Don’t take it seriously.\n" +
"• 𝐄𝐟𝐟𝐞𝐜𝐭: 𝐑𝐢𝐩\n" +
"• 𝐓𝐚𝐫𝐠𝐞𝐭: %1",
error:
"API error: %1. Contact Efx Asif for help.\n" +
"• WhatsApp: +58 426-6585612"
},
vi: {
noTarget:
"× Cưng ơi, hãy gắn thẻ, phản hồi hoặc cung cấp UID mục tiêu.",
success:
"Baby, it’s just for fun. Don’t take it seriously.\n" +
"• 𝐄𝐟𝐟𝐞𝐜𝐭: 𝐑𝐢𝐩\n" +
"• 𝐓𝐚𝐫𝐠𝐞𝐭: %1",
error:
"API error: %1. Contact Efx Asif for help.\n" +
"• WhatsApp: +58 426-6585612"
}
},
onStart: async function ({
api,
event,
args,
message,
getLang
}) {
// Author protection
const authorName = String.fromCharCode(
77,
97,
104,
77,
85,
68
);
if (this.config.author !== authorName) {
return api.sendMessage(
"You are not authorized to change the author name.",
event.threadID,
event.messageID
);
}
const {
senderID,
mentions,
messageReply,
messageID
} = event;
let id2;
let targetName = "";
// =================================================
// TARGET DETECTION
// =================================================
if (messageReply) {
id2 = messageReply.senderID;
} else if (
mentions &&
Object.keys(mentions).length > 0
) {
id2 = Object.keys(mentions)[0];
} else if (
args[0] &&
!isNaN(args[0])
) {
id2 = args[0];
} else {
id2 = senderID;
}
// =================================================
// GET TARGET USER INFO
// =================================================
try {
const userInfo =
await api.getUserInfo(id2);
if (
userInfo &&
userInfo[id2]
) {
targetName =
userInfo[id2].name ||
userInfo[id2].firstName ||
"User";
} else {
targetName = "User";
}
} catch (e) {
targetName = "User";
}
if (!id2) {
return message.reply(
getLang("noTarget")
);
}
// =================================================
// REACTION
// =================================================
api.setMessageReaction(
"⏳",
messageID,
() => {},
true
);
// =================================================
// CACHE
// =================================================
const cacheDir =
path.join(__dirname, "cache");
const filePath =
path.join(
cacheDir,
`rip_${id2}.png`
);
try {
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(
cacheDir,
{
recursive: true
}
);
}
// =================================================
// API REQUEST
// =================================================
const baseApi =
await mahmud();
const response =
await axios.get(
`${baseApi}/api/fun?type=rip&user=${id2}`,
{
responseType:
"arraybuffer",
timeout: 30000
}
);
// =================================================
// SAVE IMAGE
// =================================================
fs.writeFileSync(
filePath,
Buffer.from(
response.data
)
);
// =================================================
// SUCCESS REACTION
// =================================================
api.setMessageReaction(
"🪽",
messageID,
() => {},
true
);
// =================================================
// SEND RESULT
// =================================================
return message.reply(
{
body: getLang(
"success",
targetName
),
attachment:
fs.createReadStream(
filePath
)
},
() => {
try {
if (
fs.existsSync(
filePath
)
) {
fs.unlinkSync(
filePath
);
}
} catch (e) {
console.error(
"Cache cleanup error:",
e
);
}
}
);
} catch (err) {
console.error(
"[rip] Error:",
err
);
// =================================================
// CLEAN CACHE ON ERROR
// =================================================
try {
if (
fs.existsSync(
filePath
)
) {
fs.unlinkSync(
filePath
);
}
} catch (e) {
console.error(
"Cache cleanup error:",
e
);
}
// =================================================
// ERROR REPLY
// =================================================
return message.reply(
getLang(
"error",
err.message
)
);
}
}
};