Skip to content

commands.ColourConverter can return Colour.holographic_style() #1488

@Enegg

Description

@Enegg

Summary

ColourConverter.convert returns a tuple upon receiving the string holographic_style (or "holographic style")

Reproduction Steps

  1. Create a prefix command with a parameter annotated with commands.Color.
  2. Run the bot.
  3. Run the command, passing it holographic_style as an argument.
  4. Boom, the converter returns a tuple rather than commands.Color (or failing)

Minimal Reproducible Code

import os

import disnake
from disnake.ext import commands

intents = disnake.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix=",", intents=intents)


@bot.command()
async def woo(ctx: commands.Context, color: disnake.Color) -> None:
    await ctx.send(str(color))


bot.run(os.getenv("BOT_TOKEN"))

Expected Results

The converter should fail with an exception

Actual Results

The converter returns a tuple of 3 Colors, while it's annotated as returning a Color

Image

Intents

.default() + message_content

System Information

- Python v3.10.18-final
- disnake v2.11.0-alpha
    - disnake importlib.metadata: v2.12.0a4863+g3aa64412
- aiohttp v3.12.15
- system info: Windows 10 10.0.26100 AMD64

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

Bad code!

arg = arg.replace(" ", "_")
method = getattr(disnake.Colour, arg, None)
if arg.startswith("from_") or method is None or not inspect.ismethod(method):
raise BadColourArgument(arg)
return method()

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugSomething might not be working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions