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)
|
||||
|
|
|
@ -82,6 +82,7 @@ module.exports.ICONS = Object.freeze({
|
|||
"clock": "<:ico_clock:1263592462841020537>",
|
||||
"definition": "<:ico_definition:1263592450136473684>",
|
||||
"example": "<:ico_example:1263592408021471253>",
|
||||
"equals": "<:ico_equals:1266486823992168468>",
|
||||
"flag": "<:ico_flag:1263592391630127114>",
|
||||
"list": "<:ico_list:1263592365994803306>",
|
||||
"mag": "<:ico_mag:1263592345845108747>",
|
||||
|
|
|
@ -183,6 +183,10 @@ const Statics = Object.freeze({
|
|||
warning: {
|
||||
file: "icons/core/ico_notice_warning.png",
|
||||
revision: 3
|
||||
},
|
||||
search_calculator: {
|
||||
file: "search/calculator.78rasnkwtvo0.png",
|
||||
revision: 1
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -234,7 +238,8 @@ module.exports.STATIC_ICONS = Object.freeze({
|
|||
ai_summary: staticAsset(Statics.icons.ai_summary),
|
||||
ai_image: staticAsset(Statics.icons.ai_image),
|
||||
ai_image_processing: staticAsset(Statics.icons.ai_image_processing),
|
||||
warning: staticAsset(Statics.icons.warning)
|
||||
warning: staticAsset(Statics.icons.warning),
|
||||
search_calculator: staticAsset(Statics.icons.search_calculator)
|
||||
})
|
||||
|
||||
module.exports.STATIC_ASSETS = Object.freeze({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue