Skip to content

Instantly share code, notes, and snippets.

@weskerty
Forked from OfficialGodbless/Wikipedia.js
Last active August 24, 2025 20:40
Show Gist options
  • Select an option

  • Save weskerty/9ace4ec5d9911e7e267e53ef0ea5af05 to your computer and use it in GitHub Desktop.

Select an option

Save weskerty/9ace4ec5d9911e7e267e53ef0ea5af05 to your computer and use it in GitHub Desktop.
Wikipedia Fork Plugin pero en Español (cambiar https://es.wikipedia.org)
const { bot } = require("../lib/");
const axios = require("axios");
bot(
{
pattern: "wiki ?(.*)",
desc: "Search Wikipedia for a topic",
type: "info",
},
async (message, match) => {
try {
if (!match) return await message.send("Please provide a search query\nExample: .wiki Albert Einstein");
const response = await axios.get(
`https://es.wikipedia.org/api/rest_v1/page/summary/${encodeURIComponent(match)}`
);
const data = response.data;
const summary = data.extract || "No summary available.";
const title = data.title;
const wikiMessage = `
📖 ${title}
📝 ${summary}
🔗 ${data.content_urls.desktop.page}
`;
await message.send(wikiMessage);
} catch (error) {
console.error("Wiki Error:", error);
let errorMsg = "⚠️ Failed to fetch Wikipedia information";
if (error.response?.status === 404) {
errorMsg = "⚠️ Article not found. Try another query.";
}
await message.send(errorMsg);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment