diff --git a/example/imagine-err.ts b/example/imagine-err.ts index d45b115..97d499d 100644 --- a/example/imagine-err.ts +++ b/example/imagine-err.ts @@ -15,15 +15,14 @@ async function main() { Debug: true, }); await client.init(); - const msg = await client.Imagine( - `https://images.guapitu.com/chatgpt/5b9b907a/d3297338-ae3e-4276-9bd9-3b6ca27cedcf.png - https://images.guapitu.com/chatgpt/762a2db4/459d52f1-23fd-41c3-a912-317e65155fcc.png - https://images.guapitu.com/chatgpt/f86613ac/2e2497ae-9906-44d9-8396-e41abab2f47b.png - cat`, - (uri: string, progress: string) => { - console.log("loading", uri, "progress", progress); - } - ); + // `https://images.guapitu.com/chatgpt/5b9b907a/d3297338-ae3e-4276-9bd9-3b6ca27cedcf.png + // https://images.guapitu.com/chatgpt/762a2db4/459d52f1-23fd-41c3-a912-317e65155fcc.png + // https://images.guapitu.com/chatgpt/f86613ac/2e2497ae-9906-44d9-8396-e41abab2f47b.png + // cat` + const prompt = `%s %sTiny cute isometric Hcia illustration, a girl with long white hair, smile, seawater, colorful bubbles, dreamy portrait, Teana punk, more details, fiber tracking, snail core, Kuvshinov Ilya, yakamoz emoji, soft lighting, soft colors, matte clay, blender 3d, pastel background --v 5.1 --ar 1:1 --s 350 --q 1`; + const msg = await client.Imagine(prompt, (uri: string, progress: string) => { + console.log("loading", uri, "progress", progress); + }); console.log({ msg }); } main().catch((err) => { diff --git a/src/banned.words.ts b/src/banned.words.ts index 9592796..1ea3ace 100644 --- a/src/banned.words.ts +++ b/src/banned.words.ts @@ -1,6 +1,7 @@ // https://tokenizedhq.com/list-of-banned-words-in-midjourney/ // https://www.greataiprompts.com/imageprompt/list-of-banned-words-in-midjourney/ export const bannedWords = [ + "hot slut", "blood", "twerk", "making love", diff --git a/src/discord.ws.ts b/src/discord.ws.ts index e68b206..04be61a 100644 --- a/src/discord.ws.ts +++ b/src/discord.ws.ts @@ -17,6 +17,7 @@ import { formatInfo, formatOptions, formatPrompts, + nextNonce, uriToHash, } from "./utls"; import { VerifyHuman } from "./verify.human"; @@ -139,6 +140,12 @@ export class WsMessage { this.log("embeds[0].color", color); switch (color) { case 16711680: //error + if (title == "Action needed to continue") { + return this.continue(message); + } else if (title == "Pending mod message") { + return this.continue(message); + } + const error = new Error(description); this.EventError(id, error); return; @@ -174,6 +181,7 @@ export class WsMessage { this.messageUpdate(message); } + private messageUpdate(message: any) { // this.log("messageUpdate", message); const { @@ -298,13 +306,34 @@ export class WsMessage { } } } + //continue click appeal or Acknowledged + private async continue(message: any) { + const { components, id, flags, nonce } = message; + const appeal = components[0]?.components[0]; + this.log("appeal", appeal); + if (appeal) { + var newnonce = nextNonce(); + const httpStatus = await this.MJApi.CustomApi({ + msgId: id, + customId: appeal.custom_id, + flags, + nonce: newnonce, + }); + this.log("appeal.httpStatus", httpStatus); + if (httpStatus == 204) { + this.on(newnonce, (data) => { + this.emit(nonce, data); + }); + } + } + } private async verifyHuman(message: any) { const { HuggingFaceToken } = this.config; if (HuggingFaceToken === "" || !HuggingFaceToken) { this.log("HuggingFaceToken is empty"); return; } - const { embeds, components, id, flags } = message; + const { embeds, components, id, flags, nonce } = message; const uri = embeds[0].image.url; const categories = components[0].components; const classify = categories.map((c: any) => c.label); @@ -314,11 +343,18 @@ export class WsMessage { const custom_id = categories.find( (c: any) => c.label === category ).custom_id; + var newnonce = nextNonce(); const httpStatus = await this.MJApi.CustomApi({ msgId: id, customId: custom_id, flags, + nonce: newnonce, }); + if (httpStatus == 204) { + this.on(newnonce, (data) => { + this.emit(nonce, data); + }); + } this.log("verifyHumanApi", httpStatus, custom_id, message.id); } }