Show credit left

This commit is contained in:
Supositware 2022-10-16 22:58:31 +02:00
parent 5a8ec1dbe7
commit 06d0d3d5c5
2 changed files with 8 additions and 3 deletions

View file

@ -14,3 +14,4 @@ twiLogChannel=ChannelWhereTheDetailedInfoOfTheCommandIsSent
botsggToken=APITokenForBots.gg botsggToken=APITokenForBots.gg
botsggEndpoint=https://discord.bots.gg/api/v1 botsggEndpoint=https://discord.bots.gg/api/v1
stableHordeApi=0000000000 stableHordeApi=0000000000
stableHordeID=0000

View file

@ -3,7 +3,7 @@ import fetch from 'node-fetch';
import fs from 'node:fs'; import fs from 'node:fs';
import os from 'node:os'; import os from 'node:os';
const { stableHordeApi } = process.env; const { stableHordeApi, stableHordeID } = process.env;
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -41,11 +41,15 @@ async function generate(i, prompt, client) {
let response = await fetch('https://stablehorde.net/api/v2/generate/sync', fetchParameters); let response = await fetch('https://stablehorde.net/api/v2/generate/sync', fetchParameters);
response = await response.json(); response = await response.json();
let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`);
creditResponse = await creditResponse.json();
const stableEmbed = new EmbedBuilder() const stableEmbed = new EmbedBuilder()
.setColor(i.member ? i.member.displayHexColor : 'Navy') .setColor(i.member ? i.member.displayHexColor : 'Navy')
.setTitle(prompt) .setTitle(prompt)
.setURL('https://aqualxx.github.io/stable-ui/') .setURL('https://aqualxx.github.io/stable-ui/')
.setFooter({ text: `Seed: ${response.generations[0].seed} worker ID: ${response.generations[0].worker_id} worker name: ${response.generations[0].worker_name}` }); .setFooter({ text: `**Credit left: ${creditResponse.kudos}** Seed: ${response.generations[0].seed} worker ID: ${response.generations[0].worker_id} worker name: ${response.generations[0].worker_name}` });
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(