mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-11 23:53:05 -04:00
organize
This commit is contained in:
parent
6e1a5f1cdb
commit
5da051b3b1
8 changed files with 10 additions and 5 deletions
79
commands/message/limited/bard.js
Normal file
79
commands/message/limited/bard.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||
const { editOrReply } = require('../../../labscore/utils/message')
|
||||
|
||||
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
||||
const { STATIC_ICONS } = require('../../../labscore/utils/statics');
|
||||
|
||||
const superagent = require('superagent')
|
||||
const { iconPill } = require('../../../labscore/utils/markdown')
|
||||
|
||||
const { Permissions } = require("detritus-client/lib/constants");
|
||||
|
||||
module.exports = {
|
||||
name: 'bard',
|
||||
label: 'text',
|
||||
metadata: {
|
||||
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nChat with <:bard:1163200801871765504> Bard.`,
|
||||
description_short: 'Chat with Bard.',
|
||||
examples: ['bard How many otter species are there?'],
|
||||
category: 'limited',
|
||||
usage: 'bard <input>'
|
||||
},
|
||||
args: [],
|
||||
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
|
||||
run: async (context, args) => {
|
||||
if(!canUseLimitedTestCommands(context)) return;
|
||||
|
||||
context.triggerTyping();
|
||||
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`))
|
||||
|
||||
let input = args.text;
|
||||
|
||||
let inputDisplay = args.text.replace(/\n/g, ' ')
|
||||
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
||||
|
||||
try{
|
||||
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
||||
|
||||
let res = await superagent.post(`${process.env.AI_SERVER}/google/bard`)
|
||||
.set({
|
||||
Authorization: process.env.AI_SERVER_KEY
|
||||
})
|
||||
.send({
|
||||
input
|
||||
})
|
||||
|
||||
let description = []
|
||||
let files = [];
|
||||
|
||||
if(!res.body.output) return editOrReply(context, createEmbed("error", context, `Bard returned an error. Try again later.`))
|
||||
|
||||
if(res.body.output.length <= 4000) description.push(res.body.output)
|
||||
else {
|
||||
files.push({
|
||||
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||
value: Buffer.from(res.body.output)
|
||||
})
|
||||
}
|
||||
|
||||
return editOrReply(context, {
|
||||
embeds:[createEmbed("defaultNoFooter", context, {
|
||||
author: {
|
||||
name: inputDisplay,
|
||||
iconUrl: STATIC_ICONS.ai_bard_idle
|
||||
},
|
||||
description: description.join('\n'),
|
||||
footer: {
|
||||
text: `Bard • This information may be inaccurate or biased`
|
||||
}
|
||||
})],
|
||||
files
|
||||
})
|
||||
}catch(e){
|
||||
if(e.response.body?.message) return editOrReply(context, createEmbed("warning", context, e.response.body.message))
|
||||
|
||||
console.log(e)
|
||||
return editOrReply(context, createEmbed("error", context, `Unable to generate text.`))
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue