This commit is contained in:
derpystuff 2022-05-29 16:44:25 +02:00
parent 0ea80b7452
commit 3432604c52
10 changed files with 79 additions and 9 deletions

View file

@ -51,6 +51,7 @@ function createCommandPage(context, prefix, command){
const categories = { const categories = {
"core": `${icon("house")} Core Commands`, "core": `${icon("house")} Core Commands`,
"info": `${icon("info")} Information Commands`, "info": `${icon("info")} Information Commands`,
"utils": `${icon("utils")} Utility Commands`,
"image": `${icon("image")} Image Commands`, "image": `${icon("image")} Image Commands`,
"mod": `${icon("moderation")} Moderation Commands`, "mod": `${icon("moderation")} Moderation Commands`,
"search": `${icon("search")} Search Commands` "search": `${icon("search")} Search Commands`

View file

@ -9,7 +9,7 @@ module.exports = {
name: 'safetylabels', name: 'safetylabels',
metadata: { metadata: {
description: 'Image Safe Search Labels', description: 'Image Safe Search Labels',
examples: ['labels'], examples: ['safetylabels'],
category: 'utils', category: 'utils',
usage: 'safetylabels <attachment>' usage: 'safetylabels <attachment>'
}, },

View file

@ -4,8 +4,8 @@ const { createEmbed } = require('../../../labscore/utils/embed')
const { editOrReply } = require('../../../labscore/utils/message') const { editOrReply } = require('../../../labscore/utils/message')
module.exports = { module.exports = {
name: 'guildicon', name: 'servericon',
aliases: ["servericon","gi","si"], aliases: ["guildicon","gi","si"],
metadata: { metadata: {
description: 'server icon', description: 'server icon',
examples: ['gi'], examples: ['gi'],

View file

@ -39,14 +39,13 @@ module.exports = {
label: 'query', label: 'query',
aliases: ['urban', 'ud'], aliases: ['urban', 'ud'],
metadata: { 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'], examples: ['ud Flask'],
category: 'search', category: 'search',
usage: 'urbandictionary <query>' usage: 'urbandictionary <query>'
}, },
run: async (context, args) => { run: async (context, args) => {
context.triggerTyping(); context.triggerTyping();
if(!args.query) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (query).`)]})
try{ try{
let search = await urbandictionary(context, args.query) let search = await urbandictionary(context, args.query)
search = search.response search = search.response

View file

@ -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 <query>'
},
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.`)]})
}
},
};

View file

@ -34,7 +34,7 @@ module.exports = {
metadata: { metadata: {
description: 'Enlarge Emoji.', description: 'Enlarge Emoji.',
examples: ['enlarge 😀'], examples: ['enlarge 😀'],
category: 'util', category: 'utils',
usage: 'enlarge <emoji>' usage: 'enlarge <emoji>'
}, },
args: [ args: [

View file

@ -9,7 +9,7 @@ module.exports = {
metadata: { metadata: {
description: 'screenshot website', description: 'screenshot website',
examples: ['ss google.com'], examples: ['ss google.com'],
category: 'util', category: 'utils',
usage: 'screenshot <url>' usage: 'screenshot <url>'
}, },
run: async (context, args) => { run: async (context, args) => {

View file

@ -1,5 +1,5 @@
const Hosts = Object.freeze({ const Hosts = Object.freeze({
prod: "https://vercel-router-test.vercel.app", prod: "https://labscore-v2.vercel.app",
local: "http://localhost:3000", local: "http://localhost:3000",
emoji: "https://derpystuff.gitlab.io/webstorage3/container/", emoji: "https://derpystuff.gitlab.io/webstorage3/container/",
statics: "https://derpystuff.gitlab.io/webstorage4/v2/" statics: "https://derpystuff.gitlab.io/webstorage4/v2/"
@ -33,6 +33,7 @@ const Api = Object.freeze({
SEARCH_LYRICS: '/search/lyrics', SEARCH_LYRICS: '/search/lyrics',
SEARCH_RULE34: '/search/booru', SEARCH_RULE34: '/search/booru',
SEARCH_URBANDICTIONARY: '/search/urbandictionary', SEARCH_URBANDICTIONARY: '/search/urbandictionary',
SEARCH_WIKIHOW: '/search/wikihow',
SEARCH_WOLFRAM_ALPHA: '/search/wolfram-alpha', SEARCH_WOLFRAM_ALPHA: '/search/wolfram-alpha',
SEARCH_YOUTUBE: '/search/youtube', SEARCH_YOUTUBE: '/search/youtube',

View file

@ -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){ module.exports.wolframAlpha = async function(context, query){
return await request(Api.SEARCH_WOLFRAM_ALPHA, "GET", {}, { return await request(Api.SEARCH_WOLFRAM_ALPHA, "GET", {}, {
q: query q: query

View file

@ -35,6 +35,10 @@ const Statics = Object.freeze({
urbandictionary: { urbandictionary: {
file: "brands/urbandictionary.png", file: "brands/urbandictionary.png",
revision: 2 revision: 2
},
wikihow: {
file: "brands/wikihow.png",
revision: 1
} }
} }
}) })
@ -51,5 +55,6 @@ module.exports.STATICS = Object.freeze({
wolframalpha: staticAsset(Statics.brands.wolframalpha), wolframalpha: staticAsset(Statics.brands.wolframalpha),
inferkit: staticAsset(Statics.brands.inferkit), inferkit: staticAsset(Statics.brands.inferkit),
youtube: staticAsset(Statics.brands.youtube), youtube: staticAsset(Statics.brands.youtube),
urbandictionary: staticAsset(Statics.brands.urbandictionary) urbandictionary: staticAsset(Statics.brands.urbandictionary),
wikihow: staticAsset(Statics.brands.wikihow)
}) })