forked from VryptLab/EternityBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackoverflow.js
More file actions
18 lines (16 loc) · 826 Bytes
/
Copy pathstackoverflow.js
File metadata and controls
18 lines (16 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default {
name: "stackoverflow",
category: "developer",
command: ["so", "stack"],
run: async (conn, m) => {
const query = m.text.trim();
if (!query) return m.reply("🧠 Contoh: .so How to use async/await in Node.js");
const res = await fetch(`https://api.stackexchange.com/2.3/search/advanced?order=desc&sort=relevance&q=${encodeURIComponent(query)}&site=stackoverflow`);
const data = await res.json();
if (!data.items?.length) return m.reply("❌ Tidak ada hasil ditemukan.");
const top = data.items.slice(0, 3)
.map((q, i) => `🟢 *${i + 1}. ${q.title}*\n👤 ${q.owner.display_name}\n💬 ${q.answer_count} jawaban\n🔗 ${q.link}`)
.join("\n\n");
m.reply(`📚 *Hasil Pencarian Stack Overflow:*\n\n${top}`);
}
}