mirror of
https://github.com/Expand-sys/expandschatbot
synced 2026-03-22 12:37:10 +11:00
yeet
This commit is contained in:
parent
c117c6a55f
commit
0aa74014e5
2 changed files with 33 additions and 1589 deletions
33
commands/fun/image.js
Normal file
33
commands/fun/image.js
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
const { Configuration, OpenAIApi } = require("openai");
|
||||||
|
|
||||||
|
const configuration = new Configuration({
|
||||||
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
|
});
|
||||||
|
const openai = new OpenAIApi(configuration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'image',
|
||||||
|
description: 'AI image generation',
|
||||||
|
async execute(message, args){
|
||||||
|
let image_url = null
|
||||||
|
let error = null
|
||||||
|
try{
|
||||||
|
const response = await openai.createImage({
|
||||||
|
prompt: `${message.content.slice(7, message.content.length)}`,
|
||||||
|
n: 1,
|
||||||
|
size: "1024x1024",
|
||||||
|
});
|
||||||
|
image_url = response.data.data[0].url;
|
||||||
|
error = response
|
||||||
|
|
||||||
|
} catch(e){
|
||||||
|
error = e.response.data.error.message
|
||||||
|
}
|
||||||
|
|
||||||
|
message.channel.send(image_url || error)
|
||||||
|
|
||||||
|
;
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue