Skip to content

[BUG] color in create_role() doesn´t allow int #1464

Closed
@Donbur4156

Description

@Donbur4156

Library Version

5.7.0

Describe the Bug

the options colour and color in guild.create_role() have int as typehint included.
By passing an integer you will get an AttributeError "'int' object has no attribute 'value'"

For code reference:
interactions.py > interactions > models > discord > guild.py
lines: 1445, 1446, 1478

Steps to Reproduce

color = int("E67E22", 16))
new_role = await guild.create_role(name="rolename", color=color)

Expected Results

creating a role with given color

Minimal Reproducible Code

No response

Traceback

AttributeError: 'int' object has no attribute 'value'
  File "interactions/client/client.py", line 1890, in __dispatch_interaction
    response = await callback
  File "interactions/models/internal/command.py", line 132, in __call__
    await self.call_callback(self.callback, context)
  File "interactions/models/internal/command.py", line 198, in call_callback
    await self.call_with_binding(callback, context, **context.kwargs)  # type: ignore
  File "interactions/models/internal/callback.py", line 43, in call_with_binding
    return await callback(*args, **kwargs)
  File "/home/Discord/***.py", line 418, in create_button
    new_role = await guild.create_role(name=name, color=color)
  File "interactions/models/discord/guild.py", line 1478, in create_role
    payload["color"] = colour.value

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.
  • I have attempted to debug this myself, and I believe this issue is with the library

Additional Information

I´m not sure if "RGB integer" is something else which would work.

By creating a Color object like interactions.Color(int("E67E22", 16)) and passing it as color it works as expected.
If this is the way to go, the typehint is wrong i guess

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions