Files
Emmelia-Link-Flayer-Rewrite/commands/chat.js
Logan Cusano 14fac69ab7 Add functionality to create transactions
- Transactions work against the account balance
- Needs helper functions for users
- Needs more testing
2023-02-26 03:26:24 -05:00

46 lines
1.6 KiB
JavaScript

const { submitPromptTransaction } = require("../controllers/chatGptController");
const { SlashCommandBuilder } = require('discord.js');
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "chat");
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('chat')
.setDescription('Send a text prompt to ChatGPT')
.addStringOption(option =>
option.setName('prompt')
.setDescription('The prompt to be sent to ChatGPT')
.setRequired(true))
.addBooleanOption(option =>
option.setName('public')
.setDescription("Set this to false if you would like the message to only be visible to you.")
.setRequired(false))
.addNumberOption(option =>
option.setName('temperature')
.setDescription('Set the temperature, 0 = repetitive, 1 = random; Defaults to 0')
.setRequired(false))
.addNumberOption(option =>
option.setName('tokens')
.setDescription('The max amount of tokens to be spent')
.setRequired(false)),
example: "chat [tell me a story] [0.07] [400]", // Need to figure out the tokens
isPrivileged: false,
requiresTokens: true,
defaultTokenUsage: 100,
deferInitialReply: true,
async execute(interaction) {
try {
submitPromptTransaction(interaction, async (err, result) => {
if (err) throw err;
await interaction.editReply({ content: `${interaction.member.user} ${result.promptResult}`, ephemeral: false });
});
// Needs reply code to reply to the generation
}catch(err){
log.ERROR(err)
//await interaction.reply(err.toString());
}
}
};