#utils.get not finding role by color?

1 messages · Page 1 of 1 (latest)

tepid kelp
#

Im currently trying to locate a role that matches both a color and name

ColorRole = utils.get(
  sequence=used_component_ctx.member.roles,
  color=targetRole.color.value,
  name="Color",
)

for whatever reason, it keeps returning None

I know the role exists because ive tried printing ctx.member.roles and have found it, and have matched the value of targetRole.color.value and the role color value as well as the name being "Color"

any ideas for how to get a role by both name and color, or make utils.get work?

teal wharfBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

tepid kelp
#

I also tried this:

ColorRole = utils.find(
  lambda r: r.name == "Color" and r.color == targetRole.color,
  sequence=used_component_ctx.member.roles,
)
#

but no luck

tepid kelp
#

found a solution

#
retrieved_guild = await used_component_ctx.bot.fetch_guild(
  used_component_ctx.guild.id, force=True
)

ColorRole = utils.find(
  lambda r: (r.name == "Color")
  and (r.color.value == targetRole.color.value),
  sequence=retrieved_guild.roles,
)

basically forces an updated list of roles by getting a fresh new guild object and then matches color.value (apparently color == color doesnt work??)