MIRU_VIEW FILE
import miru
import hikari
ANIMALS = {
"Bird": ":bird:",
"Cat": ":cat:",
"Dog": ":dog:",
"Fox": ":fox:",
"Kangaroo": ":kangaroo:",
"Koala": ":koala:",
"Panda": ":panda_face:",
"Raccoon": ":raccoon:",
"Red Panda": ":panda_face:",
}
class AnimalView(miru.View):
def __init__(self, author: hikari.User) -> None:
self.author = author
super().__init__(timeout=60)
@miru.text_select(
custom_id="animal_select",
placeholder="Pick an animal",
options=[
miru.SelectOption(name, name.lower().replace(" ", "_"), emoji=emoji)
for name, emoji in ANIMALS.items()
],
)
async def select_menu(self, select: miru.TextSelect, ctx: miru.ViewContext) -> None:
animal = select.values[0]
async with ctx.app.d.client_session.get(
f"https://some-random-api.com/animal/{animal}"
) as res:
if not res.ok:
await ctx.edit_response(
f"API returned a {res.status} status :c", components=[]
)
return
data = await res.json()
embed = hikari.Embed(description=data["fact"], colour=0x3B9DFF)
embed.set_image(data["image"])
animal = animal.replace("_", " ")
await ctx.edit_response(
f"Here's a {animal} for you! :3", embed=embed, components=[]
)
async def on_timeout(self) -> None:
await self.message.edit("The menu timed out :c", components=[])
async def view_check(self, ctx: miru.ViewContext) -> bool:
return ctx.user.id == self.author.id
#Error
1 messages · Page 1 of 1 (latest)
ERROR:
Traceback (most recent call last):
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\app.py", line 1174, in invoke_application_command
await context.invoke()
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\context\base.py", line 335, in invoke
await self.command.invoke(self)
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\commands\base.py", line 799, in invoke
await self(context, **kwargs)
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\commands\base.py", line 713, in call
return await self.callback(context, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\commands\animal.py", line 17, in animal
view.start(await resp.message())
^^^^^^^^^^
AttributeError: 'AnimalView' object has no attribute 'start'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\app.py", line 1215, in handle_interaction_create_for_application_commands
await self.invoke_application_command(context)
File "C:\Users\Bigba\Documents\GitHub\Galactic-at-War\dev-env\Lib\site-packages\lightbulb\app.py", line 1192, in invoke_application_command
raise new_exc
lightbulb.errors.CommandInvocationError: An error occurred during command 'animal' invocation
this is from that tutorial
@ocean creek you have installed the wrong package versions
what you mean
can you run python -m miru for me?
the version shown should the same as specified here:
https://novanai.readthedocs.io/en/latest/lightbulb/intro.html#install-requirements
otherwise you'll need to reinstall the correct version of the requirements
not yet