Skip to content

Instantly share code, notes, and snippets.

@mifyow
Created October 31, 2025 10:33
Show Gist options
  • Select an option

  • Save mifyow/dcc257298bf3f082968384022d046ae0 to your computer and use it in GitHub Desktop.

Select an option

Save mifyow/dcc257298bf3f082968384022d046ae0 to your computer and use it in GitHub Desktop.
Uploaded via Mifinfinity-!! | Yessir
export default {
name: "sharecode",
category: "owner",
command: ["sharecode"],
settings: { owner: true },
run: async (conn, m) => {
try {
const newsletterList = [
"120363420176372236@newsletter", // ID channel utama
// "120363421657033758@newsletter", kalo mau di tambahin idch nya
];
if (!newsletterList.length) {
return m.reply("⚠️ *Belum ada ID channel diatur dalam kode!*");
}
const fullText =
m.text ||
m.body ||
m.message?.conversation ||
m.message?.extendedTextMessage?.text ||
m.args?.join(" ") ||
m.input ||
m.quoted?.text ||
"";
const input = (fullText || "").trim();
if (!input || !input.includes("|")) {
return m.reply(
`❗ *Format salah!*\nGunakan format:\n> .sharecode URL_GAMBAR|URL_TUJUAN`
);
}
const parts = input.split("|").map((x) => x.trim());
if (parts.length < 2 || parts.some((x) => !x)) {
return m.reply(`❗ Format salah!\n> .sharecode url-image|url-tujuan`);
}
const [imageUrl, targetUrl] = parts;
const titleText = `📰 *Informasi Update*\nKlik tombol di bawah untuk melanjutkan.`;
const footerText = `© 2025 Mifinfinity-MD`;
await conn.sendMessage(m.chat, { react: { text: "🔄", key: m.key } });
const interactiveMessage = {
interactiveMessage: {
title: titleText,
footer: footerText,
image: { url: imageUrl },
buttons: [
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "📂 Open Code",
url: targetUrl,
}),
},
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "🪐 My Channel",
url: "https://whatsapp.com/channel/0029Vay0apKJZg49rZz1OF33",
}),
},
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "🌐 Copy Link",
copy_code: targetUrl,
}),
},
],
},
};
let success = 0;
for (const id of newsletterList) {
try {
await conn.sendMessage(id, interactiveMessage);
console.log(`✅ Dikirim ke: ${id}`);
success++;
await new Promise((res) => setTimeout(res, 1500));
} catch (err) {
console.error(`❌ Gagal kirim ke ${id}:`, err.message);
}
}
await conn.sendMessage(m.chat, { react: { text: "✅", key: m.key } });
await m.reply(
`✅ *Berhasil mengirim pesan ke ${success}/${newsletterList.length} saluran:*\n${newsletterList.join(
"\n"
)}`
);
} catch (e) {
console.error(e);
await m.reply(`❌ *Terjadi kesalahan:* ${e.message}`);
await conn.sendMessage(m.chat, { react: { text: "❌", key: m.key } });
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment