mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
adds calculator, unit converter to google cards
This commit is contained in:
parent
288f61b2d7
commit
11d20a8334
4 changed files with 51 additions and 7 deletions
|
@ -3,9 +3,9 @@ const { paginator } = require('#client');
|
|||
|
||||
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
|
||||
const { acknowledge } = require('#utils/interactions');
|
||||
const { link, citation, icon } = require('#utils/markdown')
|
||||
const { link, citation, icon, smallPill, pill, codeblock } = require('#utils/markdown')
|
||||
const { editOrReply } = require('#utils/message')
|
||||
const { STATICS } = require('#utils/statics')
|
||||
const { STATICS, STATIC_ICONS } = require('#utils/statics')
|
||||
|
||||
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
|
||||
|
||||
|
@ -27,7 +27,10 @@ const SEARCH_CARD_TYPES = {
|
|||
SEARCH_RESULT: 1,
|
||||
KNOWLEDGE_GRAPH: 2,
|
||||
DOODLE: 3,
|
||||
ENTITY: 4
|
||||
ENTITY: 4,
|
||||
CALCULATOR: 5,
|
||||
UNIT_CONVERTER: 6,
|
||||
DICTIONARY: 7
|
||||
}
|
||||
|
||||
// TODO: create a favicon() util
|
||||
|
@ -105,6 +108,22 @@ function createSearchResultPage(context, result, doodle){
|
|||
|
||||
if(result.card.link) res.author.url = result.card.link
|
||||
|
||||
break;
|
||||
case SEARCH_CARD_TYPES.CALCULATOR:
|
||||
res = createEmbed("default", context, {
|
||||
author: {
|
||||
name: result.query,
|
||||
iconUrl: STATIC_ICONS.search_calculator
|
||||
},
|
||||
description: codeblock("ansi",[result.result]),
|
||||
footer: renderFooter(context, doodle)
|
||||
})
|
||||
break;
|
||||
case SEARCH_CARD_TYPES.UNIT_CONVERTER:
|
||||
res = createEmbed("default", context, {
|
||||
description: `### Unit Converter\n \n${smallPill(result.units[0])} ${icon("equals")} ${pill(result.units[1])}`,
|
||||
footer: renderFooter(context, doodle)
|
||||
})
|
||||
break;
|
||||
default:
|
||||
res = createEmbed("error", context, "Unknown GoogleResult Type: " + result.type)
|
||||
|
|
|
@ -2,9 +2,9 @@ const { google } = require('#api');
|
|||
const { paginator } = require('#client');
|
||||
|
||||
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed')
|
||||
const { link, citation, icon, stringwrap } = require('#utils/markdown')
|
||||
const { link, citation, icon, stringwrap, codeblock, pill, smallPill } = require('#utils/markdown')
|
||||
const { editOrReply } = require('#utils/message')
|
||||
const { STATICS } = require('#utils/statics')
|
||||
const { STATICS, STATIC_ICONS } = require('#utils/statics')
|
||||
|
||||
// TODO: Turn this into a general purpose permissions constant
|
||||
const { Permissions } = require("detritus-client/lib/constants");
|
||||
|
@ -28,7 +28,10 @@ const SEARCH_CARD_TYPES = {
|
|||
SEARCH_RESULT: 1,
|
||||
KNOWLEDGE_GRAPH: 2,
|
||||
DOODLE: 3,
|
||||
ENTITY: 4
|
||||
ENTITY: 4,
|
||||
CALCULATOR: 5,
|
||||
UNIT_CONVERTER: 6,
|
||||
DICTIONARY: 7
|
||||
}
|
||||
|
||||
// TODO: create a favicon() util
|
||||
|
@ -106,6 +109,22 @@ function createSearchResultPage(context, result, doodle){
|
|||
|
||||
if(result.card.link) res.author.url = result.card.link
|
||||
|
||||
break;
|
||||
case SEARCH_CARD_TYPES.CALCULATOR:
|
||||
res = createEmbed("default", context, {
|
||||
author: {
|
||||
name: result.query,
|
||||
iconUrl: STATIC_ICONS.search_calculator
|
||||
},
|
||||
description: codeblock("ansi",[result.result]),
|
||||
footer: renderFooter(context, doodle)
|
||||
})
|
||||
break;
|
||||
case SEARCH_CARD_TYPES.UNIT_CONVERTER:
|
||||
res = createEmbed("default", context, {
|
||||
description: `### Unit Converter\n \n${smallPill(result.units[0])} ${icon("equals")} ${pill(result.units[1])}`,
|
||||
footer: renderFooter(context, doodle)
|
||||
})
|
||||
break;
|
||||
default:
|
||||
res = createEmbed("error", context, "Unknown GoogleResult Type: " + result.type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue