0.3.2 fixed wiki loading non-existent pages, added Wikicord and Italian Mapping Wiki as sources
This commit is contained in:
parent
934af0a1e8
commit
3f13fe1ec0
4 changed files with 33 additions and 6 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
# Changelog
|
# 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)
|
## 0.3.1 (February 20, 2026)
|
||||||
|
|
||||||
* Updated package-lock.json
|
* Updated package-lock.json
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sknsybot",
|
"name": "sknsybot",
|
||||||
"version": "0.3.0",
|
"version": "0.3.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
import "./initConfig";
|
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 { MyClient } from './client';
|
||||||
import commandList from './commandList';
|
import commandList from './commandList';
|
||||||
|
|
||||||
|
|
@ -43,6 +43,10 @@ client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error(`${chalk.red('Error in command')} ${chalk.bold(`/${commandName}`)}`);
|
console.error(`${chalk.red('Error in command')} ${chalk.bold(`/${commandName}`)}`);
|
||||||
console.error(ex);
|
console.error(ex);
|
||||||
|
await interaction.followUp({
|
||||||
|
content: `Errore nel comando /${commandName}. Contattare l'amministratore del bot.`,
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,21 @@ const pageSources = {
|
||||||
'cittadeldank': {
|
'cittadeldank': {
|
||||||
url: 'https://wiki.cittadeldank.it',
|
url: 'https://wiki.cittadeldank.it',
|
||||||
name: 'Città del Dank'
|
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 = [
|
const pageSourcesAuto = [
|
||||||
'cittadeldank'
|
'cittadeldank',
|
||||||
|
'wikicord',
|
||||||
|
'mappingwikiit'
|
||||||
];
|
];
|
||||||
|
|
||||||
const data = new SlashCommandBuilder()
|
const data = new SlashCommandBuilder()
|
||||||
|
|
@ -23,6 +33,8 @@ const data = new SlashCommandBuilder()
|
||||||
.setDescription('Dove guardare')
|
.setDescription('Dove guardare')
|
||||||
.addChoices([
|
.addChoices([
|
||||||
{name: 'Città del Dank', value: 'cittadeldank'},
|
{name: 'Città del Dank', value: 'cittadeldank'},
|
||||||
|
{name: 'Wikicord', value: 'wikicord'},
|
||||||
|
{name: 'Mapping Wiki IT', value: 'mappingwikiit'},
|
||||||
{name: 'Automatico', value: 'auto'}
|
{name: 'Automatico', value: 'auto'}
|
||||||
])
|
])
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
|
|
@ -45,7 +57,13 @@ async function execute (interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
if (siteChoice === 'auto') {
|
if (siteChoice === 'auto') {
|
||||||
for (let site of pageSourcesAuto) {
|
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;
|
if (pageData) break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -57,7 +75,7 @@ async function execute (interaction: ChatInputCommandInteraction) {
|
||||||
const pageEmbed = new EmbedBuilder()
|
const pageEmbed = new EmbedBuilder()
|
||||||
.setTitle(pageData.title)
|
.setTitle(pageData.title)
|
||||||
.setURL(pageData.url)
|
.setURL(pageData.url)
|
||||||
.setDescription(pageData.summary)
|
.setDescription(pageData.summary || '...')
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: `Informazioni da ${pageData.origin}`
|
text: `Informazioni da ${pageData.origin}`
|
||||||
});
|
});
|
||||||
|
|
@ -71,7 +89,7 @@ async function execute (interaction: ChatInputCommandInteraction) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await interaction.followUp({
|
await interaction.followUp({
|
||||||
content: `Pagina **${pageName}** non trovata`
|
content: `Pagina **${pageName}** non trovata!`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue