From 06d0d3d5c57d5bf535b07d6836d80ddaa15856c3 Mon Sep 17 00:00:00 2001 From: Supositware Date: Sun, 16 Oct 2022 22:58:31 +0200 Subject: [PATCH] Show credit left --- .env.example | 3 ++- commands/fun/stablediffusion.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 3304cc2..ff477b1 100644 --- a/.env.example +++ b/.env.example @@ -13,4 +13,5 @@ twiChannel=ChannelWhereJustTheTwitterLinkAreSent twiLogChannel=ChannelWhereTheDetailedInfoOfTheCommandIsSent botsggToken=APITokenForBots.gg botsggEndpoint=https://discord.bots.gg/api/v1 -stableHordeApi=0000000000 \ No newline at end of file +stableHordeApi=0000000000 +stableHordeID=0000 \ No newline at end of file diff --git a/commands/fun/stablediffusion.js b/commands/fun/stablediffusion.js index 9e168c4..9cdd0a9 100644 --- a/commands/fun/stablediffusion.js +++ b/commands/fun/stablediffusion.js @@ -3,7 +3,7 @@ import fetch from 'node-fetch'; import fs from 'node:fs'; import os from 'node:os'; -const { stableHordeApi } = process.env; +const { stableHordeApi, stableHordeID } = process.env; export default { 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); response = await response.json(); + + let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`); + creditResponse = await creditResponse.json(); + const stableEmbed = new EmbedBuilder() .setColor(i.member ? i.member.displayHexColor : 'Navy') .setTitle(prompt) .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() .addComponents(