Skip to content

FieldsEmbed Mode Not Working at DJSv13 #69

Description

@gazmull

For upcoming release of PaginationEmbed v3

FieldsEmbed mode has an extension method formatField which still overrides the field value/s with function for array mapping, however with discordjs/discord.js#4880, now it causes the module to throw out an error due to field value/s being non-string type.

Proposed Solution

  • formatField will no longer directly pass the arguments to <FieldsEmbed>.embed.fields, instead it will be stored as a property (array of fields) in the current instance of FieldsEmbed and then all formatted fields' functions will be invoked and its output will be passed to <FieldsEmbed>.embed.fields.
    • This also means that invoking addField first is required.
    • This will remove inline option in favour of required addField invocation.
  • Name parameter will be converted to as a field identifier for resolving the desired field and will accept number type for providing the desired field's index. Number type will be added due to the case of different fields with identical field name.
Code Example

New syntax

- formatField(name: string, mapFn: Function, inline: boolean)
+ formatField(nameOrIndex: string | number, mapFn: Function)

Usage
From:

fieldsEmbed.formatField('Occupation', el => el.occupation, true);

To:

fieldsEmbed
  .addField('Occupation', 'Could not be loaded', true)
  // Or pass `0` instead of `'Occupation'`
  .formatField('Occupation', el => el.occupation)

Note: Subject to change

ps. If you got something on your mind regarding this issue, please do not hesitate to post 🥂
ps2. NICE

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/errorSomething isn't working/rightcriticalThis is important

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions