nano-shino / genshinhelper

A Discord bot to help with daily Genshin activities
MIT License
34 stars 11 forks source link

Command error #15

Closed KEKKO96 closed 3 months ago

KEKKO96 commented 3 months ago

Hello, I had to reinstall the bot and now “/profile” and “/user settings” return X command error. immagine immagine

nano-shino commented 3 months ago

This is rather hard to tell what's wrong, but it looks like a server error and not the bot's fault. I don't see this issue on my end so I can't troubleshoot it.

KEKKO96 commented 3 months ago

Here are the logs if it helps

WARNING:discord.client:PyNaCl is not installed, voice will NOT be supported
INFO:discord.client:logging in using static token
INFO:discord.gateway:Shard ID None has sent the IDENTIFY payload.
INFO:discord.gateway:Shard ID None has connected to Gateway: ["gateway-prd-us-east1-d-xf2j",{"micros":164371,"calls":["id_created",{"micros":1732,"calls":[]},"session_lookup_time",{"micros":319,"calls":[]},"session_lookup_finished",{"micros":29,"calls":[]},"discord-sessions-prd-1-36",{"micros":162005,"calls":["start_session",{"micros":136725,"calls":["discord-api-rpc-7bf695cffb-p97qx",{"micros":123126,"calls":["get_user",{"micros":44466},"get_guilds",{"micros":25521},"send_scheduled_deletion_message",{"micros":8},"guild_join_requests",{"micros":240},"authorized_ip_coro",{"micros":10}]}]},"starting_guild_connect",{"micros":55,"calls":[]},"presence_started",{"micros":254,"calls":[]},"guilds_started",{"micros":111,"calls":[]},"guilds_connect",{"micros":2,"calls":[]},"presence_connect",{"micros":24808,"calls":[]},"connect_finished",{"micros":24813,"calls":[]},"build_ready",{"micros":41,"calls":[]},"clean_ready",{"micros":1,"calls":[]},"optimize_ready",{"micros":0,"calls":[]},"split_ready",{"micros":1,"calls":[]}]}]}] (Session ID: cf4a70c7547ad59285788865a28f3010).
Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/client.py", line 400, in _run_event
    await coro(*args, **kwargs)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/bot.py", line 1178, in on_connect
    await self.sync_commands()
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/bot.py", line 754, in sync_commands
    app_cmds = await self.register_commands(
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/bot.py", line 531, in register_commands
    prefetched_commands = await self._bot.http.get_guild_commands(
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/http.py", line 367, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
INFO:root:Birthday reminder task loop is scheduled to start in 2964.0 seconds
INFO:root:Next daily checkin scan is in 13763.708947000094 seconds
INFO:root:Begin periodic real-time notes check
INFO:root:Getting real-time notes for 703679024
INFO:root:[ResinMonitor] Notifying 703679024 in 60.000 seconds.
INFO:root:Getting real-time notes for 703679024
INFO:root:Finished periodic real-time notes check
ERROR:root:Application command error
Traceback (most recent call last):
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/kekko/genshinhelper/src/handlers/user_manager.py", line 220, in settings
    user_info = await gs.request_hoyolab(
  File "/home/kekko/.local/lib/python3.10/site-packages/genshin/client/components/base.py", line 480, in request_hoyolab
    data = await self.request(url, method=method, params=params, data=data, headers=headers, **kwargs)
  File "/home/kekko/.local/lib/python3.10/site-packages/genshin/client/components/base.py", line 377, in request
    response = await self.cookie_manager.request(
  File "/home/kekko/.local/lib/python3.10/site-packages/genshin/client/manager/managers.py", line 283, in request
    return await self._request(method, url, cookies=self.cookies, **kwargs)
  File "/home/kekko/.local/lib/python3.10/site-packages/genshin/client/ratelimit.py", line 25, in inner
    x = await func(*args, **kwargs)
  File "/home/kekko/.local/lib/python3.10/site-packages/genshin/client/manager/managers.py", line 158, in _request
    raise errors.GenshinException(msg="Recieved a response with an invalid content type:\n" + content)
genshin.errors.GenshinException: Recieved a response with an invalid content type:
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

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

Traceback (most recent call last):
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1370, in _invoke
    await command.invoke(ctx)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/kekko/.local/lib/python3.10/site-packages/discord/commands/core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: GenshinException: Recieved a response with an invalid content type:
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
nano-shino commented 3 months ago

even the discord lib is getting error. discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

Where are you running this bot? I would suggest test on your own computer first

KEKKO96 commented 3 months ago

I'm running this bot on my computer, but for testing purposes I just tried to run in on Ubuntu using WSL 2 with the same result. I also tried to invite the bot in a test sever with scopes "bot" and "applications.commands" and Bot permissions "Administator" but nothing changed.

/resin and /user register works

.env settings:
# ===== REQUIRED =====

# This is your Discord bot token
BOT_TOKEN=TOKEN

# ===== OPTIONAL =====

# List of games to do check in daily. See enums at https://github.com/thesadru/genshin.py/blob/20067d558c6dab7ee9eb7c7e65e48b63f71f6fcf/genshin/types.py#L24
DAILY_CHECKIN_GAMES=GENSHIN,ZZZ

# Primogem code URLs (point to line-by-line text file or json, comma-delimited)
CODE_URL=https://www.pockettactics.com/genshin-impact/codes

# This is used to enable slash commands depending on server levels.
# Level-5 servers will have access to all slash commands.
LEVEL_1_GUILDS=
LEVEL_2_GUILDS=
LEVEL_3_GUILDS=
LEVEL_4_GUILDS=
LEVEL_5_GUILDS=

# Specific channels for the bots. Check code to see what they're for.
IMAGE_HOSTING_CHANNEL_ID=
ROUTE_CHANNEL_IDS=
NEWS_CHANNEL_IDS=
CODE_CHANNEL_IDS=

Logs with no commands:

WARNING:discord.client:PyNaCl is not installed, voice will NOT be supported
INFO:discord.client:logging in using static token
INFO:discord.gateway:Shard ID None has sent the IDENTIFY payload.
INFO:discord.gateway:Shard ID None has connected to Gateway: ["gateway-prd-us-east1-d-hgbb",{"micros":81770,"calls":["id_created",{"micros":640,"calls":[]},"session_lookup_time",{"micros":281,"calls":[]},"session_lookup_finished",{"micros":27,"calls":[]},"discord-sessions-prd-1-81",{"micros":80466,"calls":["start_session",{"micros":45112,"calls":["discord-api-rpc-84cff5674-rv59b",{"micros":41187,"calls":["get_user",{"micros":7054},"get_guilds",{"micros":3823},"send_scheduled_deletion_message",{"micros":7},"guild_join_requests",{"micros":1},"authorized_ip_coro",{"micros":9}]}]},"starting_guild_connect",{"micros":89,"calls":[]},"presence_started",{"micros":293,"calls":[]},"guilds_started",{"micros":83,"calls":[]},"guilds_connect",{"micros":1,"calls":[]},"presence_connect",{"micros":34830,"calls":[]},"connect_finished",{"micros":34836,"calls":[]},"build_ready",{"micros":48,"calls":[]},"clean_ready",{"micros":0,"calls":[]},"optimize_ready",{"micros":1,"calls":[]},"split_ready",{"micros":0,"calls":[]}]}]}] (Session ID: 7c443555b1eb2d78b3899f4396c00f6a).
INFO:root:Birthday reminder task loop is scheduled to start in 229.0 seconds
INFO:root:Next daily checkin scan is in 7428.5193660000805 seconds
INFO:root:Begin periodic real-time notes check
INFO:root:Getting real-time notes for MY_ID
INFO:root:[ResinMonitor] Notifying MY_ID in 60.000 seconds.

Logs with /user settings command:

ERROR:root:Application command error
Traceback (most recent call last):
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/kekok/genshinhelper/src/handlers/user_manager.py", line 220, in settings
    user_info = await gs.request_hoyolab(
  File "/home/kekok/.local/lib/python3.10/site-packages/genshin/client/components/base.py", line 480, in request_hoyolab
    data = await self.request(url, method=method, params=params, data=data, headers=headers, **kwargs)
  File "/home/kekok/.local/lib/python3.10/site-packages/genshin/client/components/base.py", line 377, in request
    response = await self.cookie_manager.request(
  File "/home/kekok/.local/lib/python3.10/site-packages/genshin/client/manager/managers.py", line 283, in request
    return await self._request(method, url, cookies=self.cookies, **kwargs)
  File "/home/kekok/.local/lib/python3.10/site-packages/genshin/client/ratelimit.py", line 25, in inner
    x = await func(*args, **kwargs)
  File "/home/kekok/.local/lib/python3.10/site-packages/genshin/client/manager/managers.py", line 158, in _request
    raise errors.GenshinException(msg="Recieved a response with an invalid content type:\n" + content)
genshin.errors.GenshinException: Recieved a response with an invalid content type:
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

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

Traceback (most recent call last):
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1370, in _invoke
    await command.invoke(ctx)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/kekok/.local/lib/python3.10/site-packages/discord/commands/core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: GenshinException: Recieved a response with an invalid content type:
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
nano-shino commented 3 months ago

Ohhh, it's just the /user settings command. Now that I could reproduce it I have fixed it with the newest commit. As for /profile it has been working for me so I don't know still.

image

nano-shino commented 3 months ago

I could harbor a guess though. It says that the the icon.url in this line doesn't exist:

        embed.set_author(name=data.player.nickname, icon_url=data.player.avatar.icon.url)

What UID are you trying to call it on? I'm only testing NA UIDs so it could be not working in other regions.

nano-shino commented 3 months ago

Closing this issue if there's no response soon

KEKKO96 commented 3 months ago

I could harbor a guess though. It says that the the icon.url in this line doesn't exist:

        embed.set_author(name=data.player.nickname, icon_url=data.player.avatar.icon.url)

What UID are you trying to call it on? I'm only testing NA UIDs so it could be not working in other regions.

With my UID it doesn't work (703679024), maybe it's something I need to enable on HoyoLab because it works with other EU UIDs. The /user settings also work, but sometimes returns that error.

nano-shino commented 3 months ago

The dependency lib has been put in archive mode. It doesn't receive any updates so that's why new character costumes are failing. This is why I may just remove this feature as I don't have time to maintain one myself either.

https://github.com/mrwan200/EnkaNetwork.py

nano-shino commented 3 months ago

For now I have removed the offending object to make it work for your UID. Though future changes may break it again.

KEKKO96 commented 3 months ago

Thank you!