Closed elmodor closed 1 week ago
Hello,
Thank you for opening this issue.
The order of the buttons should depend on the order in which the command [p]...buttons add
is executed. Does this not work?
Have a nice evening,
AAA3A
It does not work, no.
The latest button added via [p] commandsbuttons add MSG_ID cmd text
is appended at the end - yes. However, all other buttons which have been previously added are re-sorted based on their UUID.
This is the same behavior for the rolesbuttons as well.
I had to change the UUID in the database - then add a "dummy" button so they are getting sorted according to their UUID and then delete the fake button again.
The buttons were added to an embed created by embedutils.
Thanks for the quick response, have a nice evening as well!
Looking at the code again, by UUID I mean the key generated by
config_identifier = CogsUtils.generate_key(
length=5, existing_keys=config[f"{message.channel.id}-{message.id}"]
)
Then this is called
view = self.get_buttons(config, message)
message = await message.edit(view=view)
So the messages view is set again. But get_buttons
returns the buttons not in added order, but in UUID order:
for config_identifier in config[message]:
That's what I suspect could be the issue.
for config_identifier in config[message]:
doesn't sort config identifiers, so that's weird.
Maybe this is related to the backend. My STORAGE_TYPE
is set to postgres db. Inside the postgres DB the config is stored as json too but it is sorted based on the key - in this case the UUID. So the config is sorted based on UUIDs and hence, when read, for config_identifier in config[message]
should return the config_identifiers sorted - because that's how they are stored in the backend.
If the storage is plain json, the config might not be sorted based on the UUIDs?
Here an example how the config is stored inside the postgres db config:
{"commands_buttons":{"some_id":
{"a952j": {"emoji": "x", "command": "x", "text_button": "text", "style_button": 2},
"b39ja": {"emoji": "x", "command": "x", "text_button": "text", "style_button": 2},
"h49ah": {"emoji": "x", "command": "x", "text_button": "text", "style_button": 2},
"xh92l": {"emoji": "x", "command": "x", "text_button": "text", "style_button": 2}
}}
In this case, button "xh92l" was added first, "h49ah", then "a952j" and then "b39ja".
However, on the embed in discord the buttons are re-ordered whenever a button is added, resulting in the buttons being in order of: "a952j", "h49ah", "xh92l", "b39ja" (the last added button is always last, all others are re-ordered). Correct should be the order: "xh92l", "h49ah", "a952j", "b39ja"
What cog is this feature request for?
Rolesbuttons/Commandsbuttons
Describe the feature request in as much detail as possible
Hi there,
would it be possible to add an option for the rolesbuttons and commandsbuttons cog to specify the order of the buttons? Currently the order of the buttons is determined by their uuid.
We use the commandsbuttons for example for a music interface - and there we need a specific order of the buttons to have a proper logical order (play/stop/pause/skip etc).
So when adding a commands button I would like to specify the position of the new button. This could be done either via integer values or an alphabetic sorting similar to the uuids.