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

'Embed.author.name' positional argument #2052

Closed
3 tasks done
mahtoid opened this issue May 6, 2023 · 5 comments · Fixed by #2061 or #2063
Closed
3 tasks done

'Embed.author.name' positional argument #2052

mahtoid opened this issue May 6, 2023 · 5 comments · Fixed by #2061 or #2063
Labels
unconfirmed bug A bug report that needs triaging

Comments

@mahtoid
Copy link

mahtoid commented May 6, 2023

Summary

Trying to retrieve the embed.author.name returns missing positional argument.

Reproduction Steps

  1. Create an embed
  2. Send and capture the embed
  3. Try to access the embed.author.name
  4. See Missing 1 required positional argument: 'name' error

Minimal Reproducible Code

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())


@bot.command()
async def embed(ctx: commands.Context):
    embed = discord.Embed(
        title="Hello",
        description="abc",
    )

    message: discord.Message = await ctx.send(embed=embed)
    print(message.embeds[0].author.name)

@bot.event
async def on_ready():
    print("Alive")


if __name__ == "__main__":
    bot.run("TOKEN")

Expected Results

Return of Author or EmbedEmpty

Actual Results

File "C:\Users\matth\PycharmProjects\repo\discordChatExporterPy\DiscordChatExporterPy\chat_exporter\construct\assets\embed.py", line 110, in build_author
    author_name = self.embed.author.name
                  ^^^^^^^^^^^^^^^^^
  File "C:\Users\matth\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\embeds.py", line 704, in author
    return EmbedAuthor(**getattr(self, "_author", {}))  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: EmbedAuthor.__init__() missing 1 required positional argument: 'name'

Intents

all

System Information

- Python v3.11.1-final
- py-cord v2.4.1-final
- aiohttp v3.8.3
- system info: Windows 10 10.0.22621

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

@mahtoid mahtoid added the unconfirmed bug A bug report that needs triaging label May 6, 2023
@Lulalaby
Copy link
Member

Lulalaby commented May 8, 2023

Well if author isn't defined when you send the embed, it's obvious that it fails.
You need to check if author is missing I guess.
That doesn't seems to be a library bug.

But I might be wrong.

@Om1609 what do you think

@OmLanke
Copy link
Contributor

OmLanke commented May 9, 2023

Well if author isn't defined when you send the embed, it's obvious that it fails.
You need to check if author is missing I guess.
That doesn't seems to be a library bug.

But I might be wrong.

@Om1609 what do you think

If author was not defined then it should return EmbedEmpty or None, not raise an error.

Shouldn't name be optional here? https://github.com/Pycord-Development/pycord/blob/master/discord/embeds.py#L125

Same for text here https://github.com/Pycord-Development/pycord/blob/master/discord/embeds.py#L154

@plun1331
Copy link
Member

plun1331 commented May 9, 2023

Well if author isn't defined when you send the embed, it's obvious that it fails.
You need to check if author is missing I guess.
That doesn't seems to be a library bug.
But I might be wrong.
@Om1609 what do you think

If author was no defined then it should return EmbedEmpty or None, not raise an error.

Shouldn't name be optional here? https://github.com/Pycord-Development/pycord/blob/master/discord/embeds.py#L125

Same for text here https://github.com/Pycord-Development/pycord/blob/master/discord/embeds.py#L154

I don't believe they should be optional, we should figure out why name is missing
It's probably because author has no check to see if there's actually any data there

@plun1331
Copy link
Member

plun1331 commented May 9, 2023

What was the behavior previously like?

plun1331 added a commit that referenced this issue May 9, 2023
Fixes #2052 

Signed-off-by: plun1331 <49261529+plun1331@users.noreply.github.com>
@OmLanke
Copy link
Contributor

OmLanke commented May 9, 2023

What was the behavior previously like?

Docs state EmbedEmpty was returned if author is not set

Lulalaby pushed a commit that referenced this issue May 9, 2023
* fix: add defaults to __init__s on embed classes

Fixes #2052 

Signed-off-by: plun1331 <49261529+plun1331@users.noreply.github.com>

* Update CHANGELOG.md

Signed-off-by: plun1331 <49261529+plun1331@users.noreply.github.com>

* style(pre-commit): auto fixes from pre-commit.com hooks

---------

Signed-off-by: plun1331 <49261529+plun1331@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@Lulalaby Lulalaby reopened this May 9, 2023
@plun1331 plun1331 linked a pull request May 9, 2023 that will close this issue
9 tasks
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
4 participants