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

Exception when running slash commands in DM with bot #61

Closed
XenoTheStrange opened this issue Aug 10, 2022 · 2 comments
Closed

Exception when running slash commands in DM with bot #61

XenoTheStrange opened this issue Aug 10, 2022 · 2 comments

Comments

@XenoTheStrange
Copy link

As title. This is the exception. It fires on most commands.

Ignoring exception in on_slash_command
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/disnake/client.py", line 612, in _run_event
await coro(*args, **kwargs)
File "./bot.py", line 147, in on_slash_command
f"Executed {interaction.data.name} command in {interaction.guild.name} (ID: {interaction.guild.id}) by {interaction.author} (ID: {interaction.author.id})")
AttributeError: 'NoneType' object has no attribute 'name'

This error does not appear in channels. The f-string renders properly there.
So... either interaction.guild or interaction.data is returning NoneType I guess. Idk.

Good work! This error gets ignored and the bot continues working just fine.

@kkrypt0nn
Copy link
Owner

Hey,

Yeah that is my bad, when initially creating the template with slash commands I thought they were only available in guilds and not private messages. That's why interaction.guild will be None, there is no guild in the interaction object.

I will edit that and add a simple check to that hopefully in the coming days.

Thanks for pointing that out

@kkrypt0nn
Copy link
Owner

Fixed in commit e83677d.

It will now display the following in the terminal

Executed ping slash command by Krypton#7331 (ID: 562359123086409729) in DMs
Executed ping command by Krypton#7331 (ID: 562359123086409729) in DMs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants