Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear exception when command is run without first creating bot in server #2455

Closed
3 tasks done
telecter opened this issue May 15, 2024 · 1 comment
Closed
3 tasks done
Labels
unconfirmed bug A bug report that needs triaging

Comments

@telecter
Copy link

Summary

When a client runs an application command without there being a bot in the server, Pycord crashes with an unclear exception.

Reproduction Steps

  1. Create a Discord app
  2. Make sure to not select the "bot" install setting, and install the app on a server
  3. Create a basic Python script using Pycord as shown below
  4. Run the command created in the below script in Discord
  5. Observe any errors

Minimal Reproducible Code

import discord

bot = discord.Bot()


@bot.slash_command()
async def testcommand(ctx: discord.ApplicationContext):
    await ctx.respond("test")



bot.run("<bot token>")

Expected Results

I expected a clear error (inheriting from DiscordException at least) as to why the command failed.

Actual Results

A NameError lacking any context as to why the error occurred is shown.

Full Traceback:


  File "<virtual env>/lib/python3.12/site-packages/discord/client.py", line 766, in run
    return future.result()
           ^^^^^^^^^^^^^^^
  File "<virtual env>/lib/python3.12/site-packages/discord/client.py", line 745, in runner
    await self.start(*args, **kwargs)
  File "<virtual env>/lib/python3.12/site-packages/discord/client.py", line 709, in start
    await self.connect(reconnect=reconnect)
  File "<virtual env>/lib/python3.12/site-packages/discord/client.py", line 601, in connect
    await self.ws.poll_event()
  File "<virtual env>/lib/python3.12/site-packages/discord/gateway.py", line 605, in poll_event
    await self.received_message(msg.data)
  File "<virtual env>/lib/python3.12/site-packages/discord/gateway.py", line 555, in received_message
    func(data)
  File "<virtual env>/lib/python3.12/site-packages/discord/state.py", line 818, in parse_interaction_create
    interaction = Interaction(data=data, state=self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<virtual env>/lib/python3.12/site-packages/discord/interactions.py", line 171, in __init__
    self._from_data(data)
  File "<virtual env>/lib/python3.12/site-packages/discord/interactions.py", line 201, in _from_data
    self._guild = Guild(data=self._guild_data, state=self)
                  ^^^^^
NameError: name 'Guild' is not defined. Did you mean: 'guild'?

Intents

3243773

System Information

macOS 14.5 (Darwin 23.5.0, arm64)
Python 3.12.3

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@telecter telecter added the unconfirmed bug A bug report that needs triaging label May 15, 2024
@NeloBlivion
Copy link
Member

This was already fixed on master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants