pycord
pycord copied to clipboard
refactor: Rewrite the role tags mess
Summary
Rewrite the role tags mess.
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: ignorecomments were used, a comment is also left explaining why. - [x] I have updated the changelog to include these changes.
Yeah maybe i'll try, but it sucks when I reused method names to become properties
What are your thoughts on adding something like an enum, e.g. Role.type to describe the role type ?
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
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)
Do not merge yet
Missing testing is only twitch/ytb roles, everything else is tested.
Any news on this topic ?
@Lulalaby Any news on this btw ?
not yet :(
@Lulalaby News on this 2 ?
Nope. Still a mess