ACTUALLY fix the command
This commit is contained in:
parent
6fa8f7d33d
commit
babfd52eca
1 changed files with 10 additions and 7 deletions
|
@ -1,5 +1,8 @@
|
||||||
import { SlashCommandBuilder, EmbedBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
import os from 'node:os';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
|
|
||||||
const { stableHordeApi, stableHordeID } = process.env;
|
const { stableHordeApi, stableHordeID } = process.env;
|
||||||
|
|
||||||
|
@ -66,16 +69,16 @@ async function generate(i, prompt, client) {
|
||||||
let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`);
|
let creditResponse = await fetch(`https://stablehorde.net/api/v2/users/${stableHordeID}`);
|
||||||
creditResponse = await creditResponse.json();
|
creditResponse = await creditResponse.json();
|
||||||
|
|
||||||
const imageData = await fetch(checkResult.image);
|
await fetch(checkResult.image)
|
||||||
let imgBuffer = await imageData.arrayBuffer();
|
.then(res => res.body.pipe(fs.createWriteStream(`${os.tmpdir()}/${i.id}.webp`)));
|
||||||
imgBuffer = Buffer.from(imgBuffer).toString('base64');
|
|
||||||
const img = `data:image/${imageData.headers.get('content-type')};base64,${imgBuffer}`;
|
const generatedImg = new AttachmentBuilder(`${os.tmpdir()}/${i.id}.webp`);
|
||||||
|
|
||||||
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/')
|
||||||
.setImage(`attachment:${img}`)
|
.setImage(`attachment://${i.id}.webp`)
|
||||||
.setFooter({ text: `**Credit left: ${creditResponse.kudos}** Seed: ${checkResult.seed} worker ID: ${checkResult.worker_id} worker name: ${checkResult.worker_name}` });
|
.setFooter({ text: `**Credit left: ${creditResponse.kudos}** Seed: ${checkResult.seed} worker ID: ${checkResult.worker_id} worker name: ${checkResult.worker_name}` });
|
||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
|
@ -86,7 +89,7 @@ async function generate(i, prompt, client) {
|
||||||
.setStyle(ButtonStyle.Primary),
|
.setStyle(ButtonStyle.Primary),
|
||||||
);
|
);
|
||||||
|
|
||||||
await i.editReply({ embeds: [stableEmbed], components: [row] });
|
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
|
||||||
|
|
||||||
client.once('interactionCreate', async (interactionMenu) => {
|
client.once('interactionCreate', async (interactionMenu) => {
|
||||||
if (i.user !== interactionMenu.user) return;
|
if (i.user !== interactionMenu.user) return;
|
||||||
|
|
Loading…
Reference in a new issue