passivebot / midjourney-automation-bot

This repository hosts the Midjourney Automation Bot, a free script leveraging OpenAI's GPT-3 for automated image generation via Discord. It offers a simple web interface, customizable settings, and is MIT licensed for ease of use and adaptation.
https://harminder.dev/projects/midjourney-automation-bot/wiki/midjourney-automation-bot-overview/
MIT License
182 stars 37 forks source link

Discord or channel in non-English languages #10

Open tttollerer opened 8 months ago

tttollerer commented 8 months ago

There are various problems with the DOM addressing, e.g. if the Discord client is not set to English or the channel was not created by an English client.

This affects the following lines, for example:

145 messages = await page.query_selector_all(".messageListItem-ZZ7v6g") 154 image_elements = await page.query_selector_all('.originalLink-Azwuo9') 185 pill_value_locator = 'span.optionPillValue-2uxsMp' 258 messages = await page.query_selector_all(".messageListItem-ZZ7v6g") 395 chat_bar = page.get_by_role('textbox', name='Message #general') 404 prompt_option_selector = "#autocomplete-0 > .base-2v-uc0"

Unfortunately, there also seems to be no solution to provide the classes with whitespaces like 404 prompt_option_selector = "#autocomplete-0 > .base-2v-uc0" -> prompt_option_selector = "#autocomplete-0 > [class^='base']"

I think you have to go through the position in the DOM.

tttollerer commented 8 months ago

This is how it seems to work across different channels and languages:

145 messages = await page.query_selector_all("[class='messageListItem']") 154 image_elements = await page.query_selector_all("[class='originalLink']") 185 pill_value_locator = "span[class='optionPillValue']" 258 messages = await page.query_selector_all("[class='messageListItem']") 395 chat_bar = page.locator("div[role='textbox'][aria-label^='Message #']") 404 prompt_option_selector = "#autocomplete-0"