Add functionality to create transactions
- Transactions work against the account balance - Needs helper functions for users - Needs more testing
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const libCore = require("../libCore.js");
|
||||
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 = {
|
||||
@@ -12,6 +13,10 @@ module.exports = {
|
||||
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')
|
||||
@@ -20,23 +25,17 @@ module.exports = {
|
||||
option.setName('tokens')
|
||||
.setDescription('The max amount of tokens to be spent')
|
||||
.setRequired(false)),
|
||||
example: "chat [tell me a story] [0.07] []", // Need to figure out the tokens
|
||||
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 {
|
||||
var params = {};
|
||||
var promptText = interaction.options.getString('prompt');
|
||||
var temperature = interaction.options.getNumber('temperature');
|
||||
var maxTokens = interaction.options.getNumber('tokens') ?? this.defaultTokenUsage;
|
||||
|
||||
if (temperature) params._temperature = temperature;
|
||||
if (maxTokens) params._max_tokens = maxTokens;
|
||||
|
||||
var gptResponse = await libCore.getChat(promptText, params);
|
||||
await interaction.editReply(`${interaction.member.user} ${gptResponse}`);
|
||||
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){
|
||||
|
||||
Reference in New Issue
Block a user