mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 22:35:35 +02:00
move command from actions.js to queries.js
This commit is contained in:
parent
cf6e23390d
commit
95782fa769
2 changed files with 30 additions and 30 deletions
|
@ -1,7 +1,6 @@
|
||||||
import * as skills from '../library/skills.js';
|
import * as skills from '../library/skills.js';
|
||||||
import settings from '../../../settings.js';
|
import settings from '../../../settings.js';
|
||||||
import convoManager from '../conversation.js';
|
import convoManager from '../conversation.js';
|
||||||
import { load } from 'cheerio';
|
|
||||||
|
|
||||||
function runAsAction (actionFn, resume = false, timeout = -1) {
|
function runAsAction (actionFn, resume = false, timeout = -1) {
|
||||||
let actionLabel = null; // Will be set on first use
|
let actionLabel = null; // Will be set on first use
|
||||||
|
@ -355,35 +354,6 @@ export const actionsList = [
|
||||||
return `Mode ${mode_name} is now ${on ? 'on' : 'off'}.`;
|
return `Mode ${mode_name} is now ${on ? 'on' : 'off'}.`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: '!searchWiki',
|
|
||||||
description: 'Search the Minecraft Wiki for the given query.',
|
|
||||||
params: {
|
|
||||||
'query': { type: 'string', description: 'The query to search for.' }
|
|
||||||
},
|
|
||||||
perform: async function (agent, query) {
|
|
||||||
const url = `https://minecraft.wiki/w/${query}`
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (response.status === 404) {
|
|
||||||
return `${query} was not found on the Minecraft Wiki. Try adjusting your search term.`;
|
|
||||||
}
|
|
||||||
const html = await response.text();
|
|
||||||
const $ = load(html);
|
|
||||||
|
|
||||||
const parserOutput = $("div.mw-parser-output");
|
|
||||||
|
|
||||||
parserOutput.find("table.navbox").remove();
|
|
||||||
|
|
||||||
const divContent = parserOutput.text();
|
|
||||||
|
|
||||||
return divContent.trim();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching or parsing HTML:", error);
|
|
||||||
return `The following error occured: ${error}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: '!goal',
|
name: '!goal',
|
||||||
description: 'Set a goal prompt to endlessly work towards with continuous self-prompting.',
|
description: 'Set a goal prompt to endlessly work towards with continuous self-prompting.',
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as world from '../library/world.js';
|
||||||
import * as mc from '../../utils/mcdata.js';
|
import * as mc from '../../utils/mcdata.js';
|
||||||
import { getCommandDocs } from './index.js';
|
import { getCommandDocs } from './index.js';
|
||||||
import convoManager from '../conversation.js';
|
import convoManager from '../conversation.js';
|
||||||
|
import { load } from 'cheerio';
|
||||||
|
|
||||||
const pad = (str) => {
|
const pad = (str) => {
|
||||||
return '\n' + str + '\n';
|
return '\n' + str + '\n';
|
||||||
|
@ -214,6 +215,35 @@ export const queryList = [
|
||||||
return pad(craftingPlan);
|
return pad(craftingPlan);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: '!searchWiki',
|
||||||
|
description: 'Search the Minecraft Wiki for the given query.',
|
||||||
|
params: {
|
||||||
|
'query': { type: 'string', description: 'The query to search for.' }
|
||||||
|
},
|
||||||
|
perform: async function (agent, query) {
|
||||||
|
const url = `https://minecraft.wiki/w/${query}`
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (response.status === 404) {
|
||||||
|
return `${query} was not found on the Minecraft Wiki. Try adjusting your search term.`;
|
||||||
|
}
|
||||||
|
const html = await response.text();
|
||||||
|
const $ = load(html);
|
||||||
|
|
||||||
|
const parserOutput = $("div.mw-parser-output");
|
||||||
|
|
||||||
|
parserOutput.find("table.navbox").remove();
|
||||||
|
|
||||||
|
const divContent = parserOutput.text();
|
||||||
|
|
||||||
|
return divContent.trim();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching or parsing HTML:", error);
|
||||||
|
return `The following error occured: ${error}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '!help',
|
name: '!help',
|
||||||
description: 'Lists all available commands and their descriptions.',
|
description: 'Lists all available commands and their descriptions.',
|
||||||
|
|
Loading…
Add table
Reference in a new issue