pycord icon indicating copy to clipboard operation
pycord copied to clipboard

refactor: Rewrite the role tags mess

Open Paillat-dev opened this issue 10 months ago • 9 comments

Summary

Rewrite the role tags mess. image

Information

  • [ ] This PR fixes an issue.
  • [x] This PR adds something new (e.g. new method or parameters).
  • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...).

Checklist

  • [x] I have searched the open pull requests for duplicates.
  • [x] If code changes were made then they have been tested.
    • [x] I have updated the documentation to reflect the changes.
  • [ ] If type: ignore comments were used, a comment is also left explaining why.
  • [x] I have updated the changelog to include these changes.

Paillat-dev avatar Feb 06 '25 08:02 Paillat-dev

Yeah maybe i'll try, but it sucks when I reused method names to become properties

Paillat-dev avatar Feb 06 '25 18:02 Paillat-dev

What are your thoughts on adding something like an enum, e.g. Role.type to describe the role type ?

Paillat-dev avatar Feb 10 '25 16:02 Paillat-dev

As we previously talked on dcs, the role type enum is the best way. Like plun said, deprecated all current methods and just create the type on role. But the docs should clarify that it's calculated since it's not returned by discord

Lulalaby avatar Feb 10 '25 16:02 Lulalaby

Here is a handy snippet for testing this:

import logging
import os
from datetime import datetime, UTC
from dotenv import load_dotenv

import discord

load_dotenv()

logging.basicConfig(level=logging.DEBUG)

TOKEN = os.getenv("TOKEN_3")

bot = discord.Bot()


@bot.slash_command()
async def test_roles(ctx: discord.ApplicationContext, role: discord.Role):
    await ctx.defer()
    if not ctx.guild:
        return await ctx.respond("This command must be used in a guild.")
    fetched_role = await ctx.guild.fetch_role(role.id)
    await ctx.respond(f"""```
Role:
    {role!r}
Role tags:
    {role.tags!r}
Role tags data:
    {role.tags._data if role.tags else None}

Fetched role:
    {fetched_role!r}
Fetched role tags:
    {fetched_role.tags!r}
Fetched role tags data:
    {fetched_role.tags._data if fetched_role.tags else None}       
```""")

bot.run(TOKEN)

Paillat-dev avatar Feb 15 '25 14:02 Paillat-dev

Do not merge yet

Paillat-dev avatar Feb 15 '25 14:02 Paillat-dev

Missing testing is only twitch/ytb roles, everything else is tested.

Paillat-dev avatar Feb 16 '25 13:02 Paillat-dev

Any news on this topic ?

Paillat-dev avatar Mar 12 '25 18:03 Paillat-dev

@Lulalaby Any news on this btw ?

Paillat-dev avatar Apr 30 '25 11:04 Paillat-dev

not yet :(

Lulalaby avatar Apr 30 '25 15:04 Lulalaby

@Lulalaby News on this 2 ?

Paillat-dev avatar Sep 04 '25 17:09 Paillat-dev

Nope. Still a mess

Lulalaby avatar Sep 04 '25 17:09 Lulalaby