Skip to content

Commit

Permalink
Replicate API Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sandarutharuneth committed May 4, 2023
1 parent 1c783f5 commit 5e9576c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"common-tags": "^1.8.2",
"discord.js": "^14.6.0",
"log": "^6.3.1",
"node-replicate": "1.1.6"
"replicate": "^0.11.1"
},
"name": "midjourney-bot",
"version": "1.0.0",
Expand Down
21 changes: 12 additions & 9 deletions src/slashCommands/information/imagine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ module.exports = {
run: async (client, interaction, args) => {
await interaction.deferReply()
const prompt = interaction.options.getString("prompt")
const Replicate = (await import("replicate")).default

const replicate = await import("node-replicate")
const replicate = new Replicate({
auth: "add your replicate token here",
});

const prediction = await replicate.default.model(
"prompthero/openjourney:9936c2001faa2194a261c01381f90e65261879985476014a0a37a334593a05eb",
)
.predict({
prompt: prompt,
})
const output = await
replicate.run("prompthero/openjourney:9936c2001faa2194a261c01381f90e65261879985476014a0a37a334593a05eb", {
input: {
prompt: prompt
}
})

if (interaction.channel.nsfw === true) {

Expand All @@ -32,7 +35,7 @@ module.exports = {
new ButtonBuilder()
.setLabel(`Download`)
.setStyle(ButtonStyle.Link)
.setURL(`${prediction.output[0]}`)
.setURL(output)
.setEmoji('1083007659457912852'),
new ButtonBuilder()
.setLabel(`Support Us`)
Expand All @@ -43,7 +46,7 @@ module.exports = {
const embed = new EmbedBuilder()
.setTitle("**Your Prompt:**")
.setDescription(`**${prompt}**`)
.setImage(prediction.output[0])
.setImage(output)
.setColor('#2f3136')
.setFooter({ text: `Requested by: ${interaction.user.username} | ©️ Project Razer `,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
Expand Down

0 comments on commit 5e9576c

Please sign in to comment.