diff --git a/commands/message/core/help.js b/commands/message/core/help.js index aac4efa..54acaef 100644 --- a/commands/message/core/help.js +++ b/commands/message/core/help.js @@ -51,6 +51,7 @@ function createCommandPage(context, prefix, command){ const categories = { "core": `${icon("house")} Core Commands`, "info": `${icon("info")} Information Commands`, + "utils": `${icon("utils")} Utility Commands`, "image": `${icon("image")} Image Commands`, "mod": `${icon("moderation")} Moderation Commands`, "search": `${icon("search")} Search Commands` diff --git a/commands/message/google/safetylabels.js b/commands/message/google/safetylabels.js index 63d7c4d..169a5b4 100644 --- a/commands/message/google/safetylabels.js +++ b/commands/message/google/safetylabels.js @@ -9,7 +9,7 @@ module.exports = { name: 'safetylabels', metadata: { description: 'Image Safe Search Labels', - examples: ['labels'], + examples: ['safetylabels'], category: 'utils', usage: 'safetylabels ' }, diff --git a/commands/message/info/guildicon.js b/commands/message/info/guildicon.js index f1e6a8c..ab7ca83 100644 --- a/commands/message/info/guildicon.js +++ b/commands/message/info/guildicon.js @@ -4,8 +4,8 @@ const { createEmbed } = require('../../../labscore/utils/embed') const { editOrReply } = require('../../../labscore/utils/message') module.exports = { - name: 'guildicon', - aliases: ["servericon","gi","si"], + name: 'servericon', + aliases: ["guildicon","gi","si"], metadata: { description: 'server icon', examples: ['gi'], diff --git a/commands/message/search/urbandictionary.js b/commands/message/search/urbandictionary.js index 4bd218c..a22a29b 100644 --- a/commands/message/search/urbandictionary.js +++ b/commands/message/search/urbandictionary.js @@ -39,14 +39,13 @@ module.exports = { label: 'query', aliases: ['urban', 'ud'], metadata: { - description: 'urban dictionary definitions (might be nsfw)', + description: 'urban dictionary definitions (might be nsfw).\nproviding no search term returns random results.', examples: ['ud Flask'], category: 'search', usage: 'urbandictionary ' }, run: async (context, args) => { context.triggerTyping(); - if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]}) try{ let search = await urbandictionary(context, args.query) search = search.response diff --git a/commands/message/search/wikihow.js b/commands/message/search/wikihow.js new file mode 100644 index 0000000..7c2db25 --- /dev/null +++ b/commands/message/search/wikihow.js @@ -0,0 +1,58 @@ +const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed') +const { link, icon, highlight } = require('../../../labscore/utils/markdown') +const { editOrReply } = require('../../../labscore/utils/message') +const { STATICS } = require('../../../labscore/utils/statics') + +const { paginator } = require('../../../labscore/client'); +const { wikihow } = require('../../../labscore/api'); + +function createWikiHowPage(context, result){ + let e = createEmbed("default", context, { + description: `**${link(result.link, result.title)}**\n\n${result.snippet}`, + footer: { + iconUrl: STATICS.wikihow, + text: `WikiHow • ${context.application.name}` + } + }) + if(result.image) e.image = { + url: result.image + } + let res = {"embeds": [e]} + return res; +} + +module.exports = { + name: 'wikihow', + label: 'query', + aliases: ['wh', 'how'], + metadata: { + description: 'how do you survive??', + examples: ['wh download'], + category: 'search', + usage: 'wikihow ' + }, + run: async (context, args) => { + context.triggerTyping(); + try{ + let search = await wikihow(context, args.query) + search = search.response + + let pages = [] + + if(search.body.data.length == 0) return editOrReply(context, {embeds:[createEmbed("error", context, `No results found.`)]}) + + for(const res of search.body.data){ + pages.push(createWikiHowPage(context, res)) + } + + pages = formatPaginationEmbeds(pages) + const paging = await paginator.createPaginator({ + context, + pages + }); + }catch(e){ + console.log(e) + return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform google search.`)]}) + } + }, +}; \ No newline at end of file diff --git a/commands/message/utils/enlarge.js b/commands/message/utils/enlarge.js index 34aa29f..17d2ca9 100644 --- a/commands/message/utils/enlarge.js +++ b/commands/message/utils/enlarge.js @@ -34,7 +34,7 @@ module.exports = { metadata: { description: 'Enlarge Emoji.', examples: ['enlarge 😀'], - category: 'util', + category: 'utils', usage: 'enlarge ' }, args: [ diff --git a/commands/message/utils/screenshot.js b/commands/message/utils/screenshot.js index d6c5ccb..bfa303e 100644 --- a/commands/message/utils/screenshot.js +++ b/commands/message/utils/screenshot.js @@ -9,7 +9,7 @@ module.exports = { metadata: { description: 'screenshot website', examples: ['ss google.com'], - category: 'util', + category: 'utils', usage: 'screenshot ' }, run: async (context, args) => { diff --git a/labscore/api/endpoints.js b/labscore/api/endpoints.js index 3645280..7fe8dad 100644 --- a/labscore/api/endpoints.js +++ b/labscore/api/endpoints.js @@ -1,5 +1,5 @@ const Hosts = Object.freeze({ - prod: "https://vercel-router-test.vercel.app", + prod: "https://labscore-v2.vercel.app", local: "http://localhost:3000", emoji: "https://derpystuff.gitlab.io/webstorage3/container/", statics: "https://derpystuff.gitlab.io/webstorage4/v2/" @@ -33,6 +33,7 @@ const Api = Object.freeze({ SEARCH_LYRICS: '/search/lyrics', SEARCH_RULE34: '/search/booru', SEARCH_URBANDICTIONARY: '/search/urbandictionary', + SEARCH_WIKIHOW: '/search/wikihow', SEARCH_WOLFRAM_ALPHA: '/search/wolfram-alpha', SEARCH_YOUTUBE: '/search/youtube', diff --git a/labscore/api/index.js b/labscore/api/index.js index 50eb2f7..c6941c7 100644 --- a/labscore/api/index.js +++ b/labscore/api/index.js @@ -140,6 +140,12 @@ module.exports.urbandictionary = async function(context, query){ }) } +module.exports.wikihow = async function(context, query){ + return await request(Api.SEARCH_WIKIHOW, "GET", {}, { + q: query + }) +} + module.exports.wolframAlpha = async function(context, query){ return await request(Api.SEARCH_WOLFRAM_ALPHA, "GET", {}, { q: query diff --git a/labscore/utils/statics.js b/labscore/utils/statics.js index ddcd525..3d2a49d 100644 --- a/labscore/utils/statics.js +++ b/labscore/utils/statics.js @@ -35,6 +35,10 @@ const Statics = Object.freeze({ urbandictionary: { file: "brands/urbandictionary.png", revision: 2 + }, + wikihow: { + file: "brands/wikihow.png", + revision: 1 } } }) @@ -51,5 +55,6 @@ module.exports.STATICS = Object.freeze({ wolframalpha: staticAsset(Statics.brands.wolframalpha), inferkit: staticAsset(Statics.brands.inferkit), youtube: staticAsset(Statics.brands.youtube), - urbandictionary: staticAsset(Statics.brands.urbandictionary) + urbandictionary: staticAsset(Statics.brands.urbandictionary), + wikihow: staticAsset(Statics.brands.wikihow) }) \ No newline at end of file