#How To Fix Pagination 'list' object has no attribute 'to_dict'

1 messages · Page 1 of 1 (latest)

sage pawn
#

root/services/paginator.py:https://pastebin.com/cyGkYqwR
root/commands/gen_commands.py: https://pastebin.com/KZrMyMRG

these are the two code files that deal with the error at hand

'list' object has no attribute 'to_dict'
<Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Next' emoji=None row=None>
<disnake.interactions.message.MessageInteraction object at 0x000002996FECE970>
```that's all it gives me. I'm not sure how to fix this as I did not build this paginator class myself. Thanks in advance if anyoen has a fix.
spark ore
#

typehints are your friend

#

your all_embeds list has

  • an embed
  • a list of embeds (gen_embeds)
  • a list of embeds (staff embeds)
#

tl;dr you probably just need to use embeds.extend instead of embeds.append

sage pawn
spark ore
#

+bonk 14h

honest tangleBOT
#

agree_mark I will remind you on <t:1719490158:f> (<t:1719490158:R>)

spark ore
#

I'll check this tomorrow when my exams are over

sage pawn
sage pawn
# wet urchin Examples of the handlers?

Like instead of placing my error handlers at the bottom of each cog for the commands, I’d rather just have like a cog listener or something that handles all of my errors between commands, events, and tasks if possible. Otherwise I’m fine with 3 separate handlers

spark ore
#

for all intents and purposes I would personally recommend to handle errors where they're raised (i.e. inside the same cog as the command etc. they're raised from) except for (hopefully) a select few that are raised "everywhere" which you'd handle on a global error handler on the bot itself.

but yeah it's probably possible to make some behemoth error handler, though you'd be using methods on the bot instead of directly inside the cog iirc.

wet urchin
#

I handle all errors from a single handler peeposhrug

sage pawn
#

If it’s better to do it inside of each cog then I’d rather stay that way

sage pawn
#

another question, is it possible to limit the number of characters for a slash command required parameter? Like, I want to set the title parameter to no longer than 75 characters and the details parameter to no more than 1024 characters

#
@commands.slash_command(
    name = "bt_report",
    description = "Allows a user to report an issue with the bot",
    guild_ids = [JsonService().get_guild_id(), ]
)
@commands.has_any_role("member")
async def bt_report(self, inter, title: str, *, details: str, image_urls: str = None):
    await inter.response.defer(ephemeral=True)
```like this is my slash command. I want the title to allow a max of 75 characters and the details to allow a max of (1024-75) characters so that it doesn't go past the `disnake.Embed().add_field()`'s character amount
sand lichen
#

-d commands.Param

feral sunBOT
#
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api/app_commands.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a slash command option. This instance should be assigned to a parameter of a function representing your slash command.

See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
wet urchin
#

-d commands.String

feral sunBOT
#

class disnake.ext.commands.String```
Type depicting a string option with limited length.

See [String Lengths](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#string-lengths) for more information.

New in version 2.6.
honest tangleBOT
#

Reminder for @spark ore: <#1255407014176096257 message>
Set <t:1719439758:R>

spark ore
sage pawn
#

understandable. So in my parameters I would do

from disnake.ext.commands import Param

@commands.slash_command()
async def some_command(self, param1: Param(max_length=75)):
    pass
wet urchin
#

Not :, but =

sage pawn
#

bet. tyvm

sage pawn
#

ok another question if that's alright.

embed2 = disnake.Embed(
    color = disnake.Colour.random(),
    title = "Mek's Hub Repo",
    description = f"Click [here]({main_repo}) to view this repo."
).set_thumbnail(url="./images/main_repo_img.png")

embed3 = disnake.Embed(
    color = disnake.Colour.random(),
    title = "Mek's Hub Bot Repo",
    description = f"Click [here]({bot_repo}) to view this repo."
).set_thumbnail(url="./images/bot_repo_img.png")
```I have two files in my `root/images` folder that I am trying to use as thumbnail's on my embeds, however, it doesn't like how I've put `url="/path/to/image"`. Am I supposed to do it a different way?
wet urchin
#

Yea url is solely for web resources

feral sunBOT
#

set_thumbnail(url=..., *, file=...)```
Sets the thumbnail for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Exactly one of `url` or `file` must be passed.

Warning

Passing a [`disnake.File`](https://docs.disnake.dev/en/latest/api/messages.html#disnake.File "disnake.File") object will make the embed not reusable.

Changed in version 1.4: Passing `None` removes the thumbnail.
wet urchin
#

See the file param