PhasecoreX/docker-red-discordbot

Unable to create bot on clean install

Closed this issue · 12 comments

I am running the latest release of the full tag.
It crashes on new install ( removed everything ), still removed the venv folder and does it again.

As soon as i run the bot on first install it crashes right away.
I've tried to set it up with redbot-setup beforehands and it doesn't seem to help.

Dec 13 23:38:22 localhost.localdomain dogebot[18574]: Setting bot token...
Dec 13 23:38:23 localhost.localdomain dogebot[18574]: Starting Red-DiscordBot!
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Red - Discord Bot | Configuration process
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Pick a prefix. A prefix is what you type before a command. Example:
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: !help
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: ^ The exclamation mark (!) is the prefix in this case.
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: The prefix can be multiple characters. You will be able to change it later and add more of them.
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Choose your prefix:
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Prefix> [2024-12-14 04:38:25] [CRITICAL] red.main: The main bot task didn't handle an exception and has crashed
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Traceback (most recent call last):
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 470, in red_exception_handler
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     red_task.result()
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 356, in run_bot
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     new_token = await interactive_config(
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/redbot/core/_cli.py", line 88, in interactive_config
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     prefix = input("Prefix> ")
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:              ^^^^^^^^^^^^^^^^^
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: EOFError: EOF when reading a line
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: [2024-12-14 04:38:25] [WARNING] red.main: Attempting to die as gracefully as possible...
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: [2024-12-14 04:38:25] [INFO] red.main: Shutting down from unhandled exception
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: [2024-12-14 04:38:25] [ERROR] asyncio: Task exception was never retrieved
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: future: <Task finished name='Task-14' coro=<shutdown_handler() done, defined at /data/venv/lib/python3.11/site-packages/redbot/__main__.py:425> exception=AttributeError("'Red' object has no attribute '_AutoShardedClient__queue'")>
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: Traceback (most recent call last):
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 441, in shutdown_handler
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     await red.close()
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/redbot/core/bot.py", line 2178, in close
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     await super().close()
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 247, in close
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     await super().close()  # type: ignore
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     ^^^^^^^^^^^^^^^^^^^^^
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/discord/shard.py", line 498, in close
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     await self._closing_task
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:   File "/data/venv/lib/python3.11/site-packages/discord/shard.py", line 495, in _close
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     self.__queue.put_nowait(EventItem(EventType.clean_close, None, None))
Dec 13 23:38:25 localhost.localdomain dogebot[18574]:     ^^^^^^^^^^^^
Dec 13 23:38:25 localhost.localdomain dogebot[18574]: AttributeError: 'Red' object has no attribute '_AutoShardedClient__queue'

I am running this on podman 5.3.1 on OpenSuSe Tumbleweed with this quadlet :

[Container]
    ContainerName=dogebot
    Image=ghcr.io/phasecorex/red-discordbot:full
    AutoUpdate=registry
    Environment=TOKEN= --redacted--
    Environment=EXTRA_ARGS: --debug
    Volume=/root/red-discordbot/dogebot:/data

[Install]
    WantedBy=default.target

It seems to be an issue with discord.py, i don't know what can be the cause exactly.

Interesting! So I actually did move mine to run under Podman recently, but that's with an already existing and set up bot. I've never tried it fresh.

The error you are running into is that your TOKEN environment variable isn't being read for some reason. If it was, you would see "Setting bot token..." in the logs.

Not sure if it's just how you copy pasted it, but I don't think there should be a space between Environment=TOKEN= --redacted--. I saw you had a space in Environment=EXTRA_ARGS: --debug too, which shouldn't be there. Also of note, I think that it should be an equals sign, not colon: Environment=EXTRA_ARGS=--debug

Setting bot token is the exact line first line i copied .
The Extra_Args were to try to find the problem but even without it i had the same error.

Heres the updated logs with the debug flags fixed :

Dec 14 11:24:56 localhost.localdomain systemd[1]: Started dogebot.service.
Dec 14 11:24:56 localhost.localdomain dogebot[340388]: 818a7bbfe8f508eedb46e54f4f476c87f1642f8710d88dcd670a0006a1b2f78d
Dec 14 11:24:56 localhost.localdomain dogebot[340415]: Starting with UID/GID: 1000/1000
Dec 14 11:24:56 localhost.localdomain dogebot[340415]: Activating Python virtual environment...
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Updating Red-DiscordBot[postgres]...
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: wheel in /data/venv/lib/python3.11/site-packages (0.45.1)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: Red-DiscordBot[postgres] in /data/venv/lib/python3.11/site-packages (3.5.13)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: aiohttp==3.9.5 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.9.5)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: aiohttp-json-rpc==0.13.3 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.13.3)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: aiosignal==1.3.1 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.3.1)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: apsw==3.46.1.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.46.1.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: attrs==24.2.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (24.2.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: babel==2.16.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (2.16.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: brotli==1.1.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.1.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: click==8.1.7 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (8.1.7)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: discord-py==2.4.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (2.4.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: frozenlist==1.4.1 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.4.1)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: idna==3.8 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.8)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: markdown==3.7 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.7)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: markdown-it-py==3.0.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.0.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: mdurl==0.1.2 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.1.2)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: multidict==6.0.5 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (6.0.5)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: orjson==3.10.7 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.10.7)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: packaging==24.1 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (24.1)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: platformdirs==4.2.2 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (4.2.2)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: psutil==6.0.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (6.0.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: pygments==2.18.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (2.18.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: python-dateutil==2.9.0.post0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (2.9.0.post0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: pyyaml==6.0.2 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (6.0.2)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: rapidfuzz==3.9.6 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (3.9.6)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: red-commons==1.0.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.0.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: red-lavalink==0.11.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.11.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: rich==13.8.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (13.8.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: schema==0.7.7 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.7.7)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: six==1.16.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.16.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: typing-extensions==4.12.2 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (4.12.2)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: yarl==1.9.4 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.9.4)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: uvloop==0.20.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.20.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: distro==1.9.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (1.9.0)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: async-timeout==4.0.3 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (4.0.3)
Dec 14 11:25:03 localhost.localdomain dogebot[340415]: Requirement already satisfied: asyncpg==0.29.0 in /data/venv/lib/python3.11/site-packages (from Red-DiscordBot[postgres]) (0.29.0)
Dec 14 11:25:04 localhost.localdomain dogebot[340415]: Setting bot token...
Dec 14 11:25:05 localhost.localdomain dogebot[340415]: Starting Red-DiscordBot!
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: /data/venv/lib/python3.11/site-packages/discord/player.py:29: DeprecationWarning: 'audioop' is deprecated and slated for removal in Python 3.13
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   import audioop
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [DEBUG] red.main: ====Basic Config====
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [DEBUG] red.main: Data Path: /config/.local/share/Red-DiscordBot/data/docker
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [DEBUG] red.main: Storage Type: Postgres
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Red - Discord Bot | Configuration process
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: 
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: 
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Pick a prefix. A prefix is what you type before a command. Example:
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: !help
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: ^ The exclamation mark (!) is the prefix in this case.
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: The prefix can be multiple characters. You will be able to change it later and add more of them.
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Choose your prefix:
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: 
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Prefix> [2024-12-14 16:25:06] [CRITICAL] red.main: The main bot task didn't handle an exception and has crashed
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Traceback (most recent call last):
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 470, in red_exception_handler
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     red_task.result()
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 356, in run_bot
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     new_token = await interactive_config(
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/redbot/core/_cli.py", line 88, in interactive_config
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     prefix = input("Prefix> ")
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:              ^^^^^^^^^^^^^^^^^
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: EOFError: EOF when reading a line
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [WARNING] red.main: Attempting to die as gracefully as possible...
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [INFO] red.main: Shutting down from unhandled exception
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: [2024-12-14 16:25:06] [ERROR] asyncio: Task exception was never retrieved
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: future: <Task finished name='Task-14' coro=<shutdown_handler() done, defined at /data/venv/lib/python3.11/site-packages/redbot/__main__.py:425> exception=AttributeError("'Red' object has no attribute '_AutoShardedClient__queue'")>
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: Traceback (most recent call last):
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/redbot/__main__.py", line 441, in shutdown_handler
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     await red.close()
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/redbot/core/bot.py", line 2178, in close
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     await super().close()
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 247, in close
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     await super().close()  # type: ignore
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     ^^^^^^^^^^^^^^^^^^^^^
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/discord/shard.py", line 498, in close
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     await self._closing_task
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:   File "/data/venv/lib/python3.11/site-packages/discord/shard.py", line 495, in _close
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     self.__queue.put_nowait(EventItem(EventType.clean_close, None, None))
Dec 14 11:25:06 localhost.localdomain dogebot[340415]:     ^^^^^^^^^^^^
Dec 14 11:25:06 localhost.localdomain dogebot[340415]: AttributeError: 'Red' object has no attribute '_AutoShardedClient__queue'

Found the error ... missing prefix ...

Ah, yeah your original log totally had that line lol. I don't know how I missed that...

But yeah, you need a prefix and a token for it to be initialized correctly. After it has started once, you are free to remove them from your Podman .container file.

I have added a check on container startup that will make sure the token and prefix are configured correctly. If they are missing, it will print a clean error message instead of the confusing one above. Should be built and deployed in 10 minutes or so.

@PhasecoreX This has broken my instance, I have these values as ENV Vars.

And as there's no recent older docker images around, my instance is permanently down atm...

Can you post how you are running the container (docker-compose, docker run, podman, etc.)? Also if you look in your /data/core/settings.json file, you should see something like:

{"0": {"GLOBAL": {"token": "some_token_here", "prefix": [".", "!", "etc"], ...

Do you see that? If you want you can post that too, but it has a lot of sensitive info in it. Basically, it needs to be a json file with a top key of "0" and then a "GLOBAL" section, with "token" and "prefix".

I'm using Portainer with docker compose. The relevent section for rebot is:

red-discordbot:
        container_name: annabelle-redbot
        network_mode: docker-secure
        environment:
            - TZ=Pacific/Auckland
            - HOST_OS=Unraid
            - HOST_HOSTNAME=Atlantis
            - HOST_CONTAINERNAME=annabelle-redbot
            - PREFIX=~
            - TOKEN={Redacted}
            - STORAGE_TYPE=postgres
            - 'STORAGE_DETAILS={ "host": "alteria-postgres", "port": null, "user": "annabelle-redbot-test", "password": "{REDACTED}", "database": "annabelle-redbot" }'
            - EXTRA_ARGS=
            - PUID=99
            - PGID=100
        labels:
            - 'net.unraid.docker.icon=https://raw.githubusercontent.com/selfhosters/unRAID-CA-templates/master/templates/img/red-discordbot.png'
        volumes:
            - '/mnt/user/appdata/annabelle-redbot:/data:rw'
        image: 'sha256:54ed0e8c936b807ce23b1e0da953949d7979fbcdf465cdfac5044d5f054bbb33'

I've found how to use my old image of the container, so that's being used here. So the sense of urgency is no longer there.

I'm using a db instead of the file, but I can see the right values for them saved in there.

Ah, that will do it, totally forgot non-JSON setups were a thing. I will fix that shortly, sorry about that!

No problem, will let you know if it's good once patched.

Though this suggest maybe an issue of not using ENV values provided when it's not found in the config. Would be a good fallback.

@Ryonez Okay, images were pushed, please try again.

It's already set up that if the TOKEN/PREFIX environment variables are not provided, it won't set them. The issue is that if the user doesn't specify them both on the first run, it breaks things and spits out an error. But, they can be excluded from subsequent runs (they are already written to config file).

My fix is for the default JSON setup. For someone like you using postgres, I shouldn't be doing the checks, as you probably know what you are doing already :)

Seems to be going good, thank you.