Compare commits
No commits in common. "008029b49fbbf2778f6c70a7f98292f374d8a483" and "6fa8f7d33daf5ab16caa2e609a7055d89e498f08" have entirely different histories.
008029b49f
...
6fa8f7d33d
2 changed files with 7 additions and 10 deletions
|
@ -1,8 +1,5 @@
|
||||||
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } from 'discord.js';
|
import { SlashCommandBuilder, EmbedBuilder, 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;
|
||||||
|
|
||||||
|
@ -69,16 +66,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();
|
||||||
|
|
||||||
await fetch(checkResult.image)
|
const imageData = await fetch(checkResult.image);
|
||||||
.then(res => res.body.pipe(fs.createWriteStream(`${os.tmpdir()}/${i.id}.webp`)));
|
let imgBuffer = await imageData.arrayBuffer();
|
||||||
|
imgBuffer = Buffer.from(imgBuffer).toString('base64');
|
||||||
const generatedImg = new AttachmentBuilder(`${os.tmpdir()}/${i.id}.webp`);
|
const img = `data:image/${imageData.headers.get('content-type')};base64,${imgBuffer}`;
|
||||||
|
|
||||||
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://${i.id}.webp`)
|
.setImage(`attachment:${img}`)
|
||||||
.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()
|
||||||
|
@ -89,7 +86,7 @@ async function generate(i, prompt, client) {
|
||||||
.setStyle(ButtonStyle.Primary),
|
.setStyle(ButtonStyle.Primary),
|
||||||
);
|
);
|
||||||
|
|
||||||
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
|
await i.editReply({ embeds: [stableEmbed], components: [row] });
|
||||||
|
|
||||||
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