hypergonial / hikari-miru

A component handler for hikari, inspired by discord.py's views.
https://miru.hypergonial.com/
MIT License
71 stars 18 forks source link

link buttons cannot be added #17

Closed h-lunah closed 2 years ago

h-lunah commented 2 years ago

When I try to add link buttons with the following code, an error is raised and it doesn't work.

view = miru.View()
view.add_item(miru.Button(label="View Online", url=str(ctx.options.user.display_avatar_url)))
return await ctx.respond(e, components=view.build())

The issue lies in https://github.com/HyperGH/hikari-miru/blob/main/miru/button.py#L127 and causes a following error:

Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\lightbulb\app.py", line 994, in handle_message_create_for_prefix_commands
    await self.process_prefix_commands(context)
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\lightbulb\app.py", line 966, in process_prefix_commands
    await context.invoke()
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\lightbulb\context\base.py", line 292, in invoke
    await self.command.invoke(self)
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\lightbulb\commands\prefix.py", line 112, in invoke
    await self(context)
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\lightbulb\commands\base.py", line 435, in __call__
    return await self.callback(context)
  File "D:\Coding\Iodine\cogs\tools.py", line 41, in avatar
    view.add_item(miru.Button(label="View Online", url=str(ctx.options.user.display_avatar_url)))
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\miru\button.py", line 109, in __init__
    self.style = hikari.ButtonStyle.LINK
  File "C:\Users\User\PycharmProjects\h\iodine\lib\site-packages\miru\button.py", line 128, in style
    raise ValueError("A link button cannot have it's style changed. Remove the url first.")
ValueError: A link button cannot have it's style changed. Remove the url first.
hypergonial commented 2 years ago

A fix for this should now be live on pypi (1.1.0).