From 3f13fe1ec09bbb2949b5ef4d4df52a3b5e18ec4e Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Fri, 20 Feb 2026 18:11:03 +0100 Subject: [PATCH] 0.3.2 fixed wiki loading non-existent pages, added Wikicord and Italian Mapping Wiki as sources --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/bot.ts | 6 +++++- src/commands/wiki.ts | 26 ++++++++++++++++++++++---- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5382b23..48671ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.3.2 (February 20, 2026) + +* Fixed `/wiki` loading non-existent pages. +* Added [Wikicord](https://wikicord.wikioasis.org/) and [Italian Mapping Wiki](https://it.mappingwiki.org/) as sources for `/wiki`. + ## 0.3.1 (February 20, 2026) * Updated package-lock.json diff --git a/package.json b/package.json index bc00975..7556119 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sknsybot", - "version": "0.3.0", + "version": "0.3.2", "private": true, "description": "", "license": "Apache-2.0", diff --git a/src/bot.ts b/src/bot.ts index 5174e8b..86bee5f 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -16,7 +16,7 @@ limitations under the License. import "./initConfig"; -import { GatewayIntentBits, Events, Interaction, ChatInputCommandInteraction, Guild } from 'discord.js'; +import { GatewayIntentBits, Events, Interaction, ChatInputCommandInteraction, Guild, MessageFlags } from 'discord.js'; import { MyClient } from './client'; import commandList from './commandList'; @@ -43,6 +43,10 @@ client.on(Events.InteractionCreate, async (interaction: Interaction) => { } catch (ex) { console.error(`${chalk.red('Error in command')} ${chalk.bold(`/${commandName}`)}`); console.error(ex); + await interaction.followUp({ + content: `Errore nel comando /${commandName}. Contattare l'amministratore del bot.`, + ephemeral: true + }); } } }); diff --git a/src/commands/wiki.ts b/src/commands/wiki.ts index 4dcd039..3385271 100644 --- a/src/commands/wiki.ts +++ b/src/commands/wiki.ts @@ -5,11 +5,21 @@ const pageSources = { 'cittadeldank': { url: 'https://wiki.cittadeldank.it', name: 'Città del Dank' + }, + 'wikicord': { + url: 'https://wikicord.wikioasis.org/api.php', + name: 'Wikicord' + }, + 'mappingwikiit': { + url: 'https://it.mappingwiki.org', + name: 'Mapping Wiki IT' } } const pageSourcesAuto = [ - 'cittadeldank' + 'cittadeldank', + 'wikicord', + 'mappingwikiit' ]; const data = new SlashCommandBuilder() @@ -23,6 +33,8 @@ const data = new SlashCommandBuilder() .setDescription('Dove guardare') .addChoices([ {name: 'Città del Dank', value: 'cittadeldank'}, + {name: 'Wikicord', value: 'wikicord'}, + {name: 'Mapping Wiki IT', value: 'mappingwikiit'}, {name: 'Automatico', value: 'auto'} ]) .setRequired(false) @@ -45,7 +57,13 @@ async function execute (interaction: ChatInputCommandInteraction) { if (siteChoice === 'auto') { for (let site of pageSourcesAuto) { - pageData = await fetchPageFromSite(site, pageName); + try { + pageData = await fetchPageFromSite(site, pageName); + } catch (error) { + console.warn(`Skipping source ${site}: ${error}`); + continue; + } + if (pageData) break; } } else { @@ -57,7 +75,7 @@ async function execute (interaction: ChatInputCommandInteraction) { const pageEmbed = new EmbedBuilder() .setTitle(pageData.title) .setURL(pageData.url) - .setDescription(pageData.summary) + .setDescription(pageData.summary || '...') .setFooter({ text: `Informazioni da ${pageData.origin}` }); @@ -71,7 +89,7 @@ async function execute (interaction: ChatInputCommandInteraction) { }); } else { await interaction.followUp({ - content: `Pagina **${pageName}** non trovata` + content: `Pagina **${pageName}** non trovata!` }); }