Avoid stupid leak?
This commit is contained in:
parent
332f1730d6
commit
5a8ec1dbe7
1 changed files with 12 additions and 12 deletions
|
@ -16,20 +16,11 @@ export default {
|
||||||
category: 'fun',
|
category: 'fun',
|
||||||
async execute(interaction, args, client) {
|
async execute(interaction, args, client) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
generate(interaction, args.prompt);
|
generate(interaction, args.prompt, client);
|
||||||
|
|
||||||
client.on('interactionCreate', async (interactionMenu) => {
|
|
||||||
if (interaction.user !== interactionMenu.user) return;
|
|
||||||
if (!interactionMenu.isButton) return;
|
|
||||||
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}`) {
|
|
||||||
await interactionMenu.deferReply();
|
|
||||||
await generate(interactionMenu, args.prompt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
async function generate(i, prompt) {
|
async function generate(i, prompt, client) {
|
||||||
const body = {
|
const body = {
|
||||||
prompt: prompt,
|
prompt: prompt,
|
||||||
params: {
|
params: {
|
||||||
|
@ -60,11 +51,20 @@ async function generate(i, prompt) {
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`regenerate${i.user.id}`)
|
.setCustomId(`regenerate${i.user.id}`)
|
||||||
.setLabel('🔄')
|
.setLabel('🔄 Regenerate')
|
||||||
.setStyle(ButtonStyle.Primary),
|
.setStyle(ButtonStyle.Primary),
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync(`${os.tmpdir()}/${i.id}.png`, response.generations[0].img, 'base64');
|
fs.writeFileSync(`${os.tmpdir()}/${i.id}.png`, response.generations[0].img, 'base64');
|
||||||
|
|
||||||
await i.editReply({ embeds: [stableEmbed], components: [row], files: [`${os.tmpdir()}/${i.id}.png`] });
|
await i.editReply({ embeds: [stableEmbed], components: [row], files: [`${os.tmpdir()}/${i.id}.png`] });
|
||||||
|
|
||||||
|
client.once('interactionCreate', async (interactionMenu) => {
|
||||||
|
if (i.user !== interactionMenu.user) return;
|
||||||
|
if (!interactionMenu.isButton) return;
|
||||||
|
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}`) {
|
||||||
|
await interactionMenu.deferReply();
|
||||||
|
await generate(interactionMenu, prompt, client);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue