-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from erictik:zcpua/issue5
Upscale no msg return
- Loading branch information
Showing
4 changed files
with
78 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,45 @@ | ||
type TaskFunction<T> = () => Promise<T>; | ||
|
||
interface QueueTask<T> { | ||
task: TaskFunction<T>; | ||
callback: (result: T) => void; | ||
import "dotenv/config"; | ||
import { Midjourney } from "../src"; | ||
/** | ||
* | ||
* a simple example of how to use the imagine command | ||
* ``` | ||
* npx tsx test/test.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.RetrieveMessages(10); | ||
console.log(JSON.stringify(msg)); | ||
} | ||
import async from "async"; | ||
|
||
const queue = async.queue(async ({ task, callback }: QueueTask<any>) => { | ||
const result = await task(); | ||
callback(result); | ||
}, 10); | ||
|
||
const task1: TaskFunction<number> = async () => { | ||
// do some async work | ||
return 42; | ||
}; | ||
|
||
queue.push({ | ||
task: task1, | ||
callback: (result: number) => { | ||
console.log(result); // output: 42 | ||
}, | ||
}); | ||
queue.push({ | ||
task: task1, | ||
callback: (result: number) => { | ||
console.log(result); // output: 42 | ||
}, | ||
}); | ||
|
||
queue.push({ | ||
task: task1, | ||
callback: (result: number) => { | ||
console.log(result); // output: 42 | ||
}, | ||
}); | ||
|
||
queue.push({ | ||
task: task1, | ||
callback: (result: number) => { | ||
console.log(result); // output: 42 | ||
}, | ||
}); | ||
// main().catch((err) => { | ||
// console.error(err); | ||
// process.exit(1); | ||
// }); | ||
function test2() { | ||
const item = { | ||
content: | ||
"**a cool cat, blue ears, blue hat --seed 9113 --v 5** - Image #2 <@1017020769332637730>", | ||
}; | ||
const options = "Upscaled"; | ||
const index = 2; | ||
// if (options === "Upscaled" && !item.content.includes(` - Image #${index}`)) { | ||
// console.log("123123"); | ||
// } | ||
if ( | ||
item.content.includes(options) || | ||
(options === "Upscaled" && item.content.includes(` - Image #${index}`)) | ||
) { | ||
console.log("has options"); | ||
} else { | ||
console.log("no options"); | ||
return; | ||
} | ||
console.log("no options"); | ||
} | ||
test2(); |