typing indicator

This commit is contained in:
derpystuff 2023-08-11 00:15:29 +02:00
parent 9716fb1f6e
commit dca55fd80c
4 changed files with 19 additions and 1 deletions

View file

@ -34,6 +34,8 @@ module.exports = {
if(args.prompt !== "") prompt = args.prompt
try{
await editOrReply(context, createEmbed("typing", context, "Generating response..."))
let res = await superagent.post(`${process.env.AI_SERVER}/openai`)
.set({
Authorization: process.env.AI_SERVER_KEY

View file

@ -24,6 +24,8 @@ module.exports = {
context.triggerTyping();
if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]})
try{
await editOrReply(context, createEmbed("typing", context, "Generating response..."))
let res = await superagent.post(`${process.env.AI_SERVER}/openai`)
.set({
Authorization: process.env.AI_SERVER_KEY

View file

@ -78,6 +78,15 @@ const embedTypes = Object.freeze({
},
color: COLORS.embed
}
},
"typing": (context) => {
return {
author: {
iconUrl: STATIC_ICONS.typing,
name: `Loading`
},
color: COLORS.embed
}
}
})
@ -87,7 +96,7 @@ module.exports.createEmbed = function(type, context, content){
if(!content) embedTypes[type](context)
let emb = embedTypes[type](context)
if(["success","warning","error","loading"].includes(type)){
if(["success","warning","error","loading","typing"].includes(type)){
emb.author.name = content
return emb
}

View file

@ -102,6 +102,10 @@ const Statics = Object.freeze({
file: "icons/core/ico_notice_loading.gif",
revision: 0
},
typing: {
file: "icons/core/ico_notice_typing.gif",
revision: 0
},
warning: {
file: "icons/core/ico_notice_warning.png",
revision: 0
@ -145,5 +149,6 @@ module.exports.STATIC_ICONS = Object.freeze({
adult: staticAsset(Statics.icons.adult),
error: staticAsset(Statics.icons.error),
loading: staticAsset(Statics.icons.loading),
typing: staticAsset(Statics.icons.typing),
warning: staticAsset(Statics.icons.warning)
})