Skip to content

Commit

Permalink
fixbug: prompt to add uri does not return
Browse files Browse the repository at this point in the history
  • Loading branch information
zcpua committed May 13, 2023
1 parent ace5cb0 commit b68f3c6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
28 changes: 28 additions & 0 deletions example/imagine-uri.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "dotenv/config";
import { Midjourney } from "../src";
/**
*
* a simple example of how to use the imagine command
* ```
* npx tsx example/imagine-uri.ts
* ```
*/
async function main() {
const client = new Midjourney(
<string>process.env.SERVER_ID,
<string>process.env.CHANNEL_ID,
<string>process.env.SALAI_TOKEN,
true
);
const msg = await client.Imagine(
"https://media.discordapp.net/attachments/1094892992281718894/1106660210380132503/Soga_A_Greek_man_with_mustache_in_national_costume_riding_a_don_3255e7c1-38ee-4892-b7c7-9f0dc3f2786d.png?width=1040&height=1040 https://cdn.discordapp.com/attachments/1094892992281718894/1106798152188702720/Soga__489d80b2-db74-4a93-a998-881a9542abbe.png cool boy",
(uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
console.log({ msg });
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
7 changes: 6 additions & 1 deletion src/midjourney.message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ export class MidjourneyMessage {
options?: string,
index?: number
) {
// remove urls
prompt = prompt.replace(/\bhttps?:\/\/\S+/gi, "");
// remove multiple spaces
prompt = prompt.trim();

const data = await this.safeRetrieveMessages(this.Limit);
for (let i = 0; i < data.length; i++) {
const item = data[i];
if (
item.author.id === "936929561302675456" &&
item.content.includes(`**${prompt}`)
item.content.includes(`${prompt}`)
) {
this.log(JSON.stringify(item));
// Upscaled or Variation
Expand Down

0 comments on commit b68f3c6

Please sign in to comment.