Kilvoctu / aiyabot

A neat Discord bot for AUTOMATIC1111's Web UI
GNU General Public License v2.0
311 stars 77 forks source link

Discord Bot Not Working #222

Closed MissSinful closed 8 months ago

MissSinful commented 1 year ago

Using a fresh install I run launcher.bat. it collects needed files from requirements.txt It then runs the core/setup_generate.py and downloads needed files.

The error seems to happen in the aiya.py step and the luancher shows this in the console but the bot does show as online on the discord server but with no /commands available.

Ignoring exception in on_connect
Traceback (most recent call last):
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\venv\lib\site-packages\discord\client.py", line 378, in _run_event
    await coro(*args, **kwargs)
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\venv\lib\site-packages\discord\bot.py", line 1164, in on_connect
    await self.sync_commands()
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\venv\lib\site-packages\discord\bot.py", line 719, in sync_commands
    registered_commands = await self.register_commands(
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\venv\lib\site-packages\discord\bot.py", line 599, in register_commands
    registered = await register("bulk", data, _log=False)
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\venv\lib\site-packages\discord\http.py", line 371, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.8.choices: Must be 25 or fewer in length.
In 1.options.7.choices: Must be 25 or fewer in length.
[2023-09-15 06:40:35] INFO: Logged in as Stable DiffusionV2 (1152158472549449788)
I'm active in 549666313195225108 a.k.a The Cat Cantina!

image


When i try running aiya.py without the luancher i get an error that fails the import discord.

import asyncio
import discord<----

i manually install discord using pip install discord and then i get this error.

D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main>venv\Scripts\python.exe aiya.py
Traceback (most recent call last):
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\aiya.py", line 5, in <module>
    from core import ctxmenuhandler
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\core\ctxmenuhandler.py", line 7, in <module>
    from core import settings
  File "D:\AI Art\stable-diffusion-webui\extensions\sd-webui-discord\aiyabot-main\core\settings.py", line 13, in <module>
    self = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'

Not sure where to go from here so im hoping someone here could give some more insight 😅

solareon commented 1 year ago

Please look at the pull request #221. This fixes this issue until @Kilvoctu can merge the PR you can either add the changes manually or pull from that branch on my fork.

MissSinful commented 1 year ago

Please look at the pull request #221. This fixes this issue until @Kilvoctu can merge the PR you can either add the changes manually or pull from that branch on my fork.

Thank you so much, I was able to get it working now :3

MysticDaedra commented 1 year ago

Posting this here because #221 hasn't been merged yet it seems. Adding the fixes from @solareon 's fork is allowing the bot to accept commands on my Discord server now, but I see in command prompt that it's returning an error:


Ignoring exception in command draw:
Traceback (most recent call last):
  File "F:\aiyabot\venv\lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "F:\aiyabot\venv\lib\site-packages\discord\commands\core.py", line 978, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "F:\aiyabot\core\stablecog.py", line 202, in dream_handler
    if settings.read(channel)['n_prefix'] != "":
KeyError: 'n_prefix'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\aiyabot\venv\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "F:\aiyabot\venv\lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "F:\aiyabot\venv\lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: KeyError: 'n_prefix'

It says "ignoring exception", but an error was returned in Discord as well. I know virtually nothing about Python, but I'm not afraid to get my hands dirty in the code if need be. This, however, is solidly outside of my capabilities to troubleshoot. Thanks in advance for any help.

EDIT: All commands, including /settings, is returning in Discord a "the application did not respond" error. Bot has all permissions, should be good to go...

solareon commented 1 year ago

@MysticDaedra did you check that you are running Python 3.10 or later? I believe some one else had a similar issue due to an outdated Python version

MysticDaedra commented 1 year ago

Yes, I am running Python 3.10, Stable Diffusion reads that out in Command Prompt and I don't have any other versions of Python installed.

I noticed when running launch.bat that it said it could not find python.exe in the venv<Scripts folder, but it is indeed there.

solareon commented 1 year ago

@MysticDaedra could you try running the lines in the launch.bat one at a time in a command prompt and paste a screenshot of the output?

Kilvoctu commented 8 months ago

Closing, as the associated PR has been merged.