TsubakiBotPad / pad-cogs

Cogs for a Discord bot related to the mobile game Puzzle & Dragons
MIT License
10 stars 2 forks source link

Make AEP keys case-insensitive #1830

Open RheingoldRiver opened 1 year ago

RheingoldRiver commented 1 year ago

image

boo

Alianin commented 1 year ago

Am I understanding the function properly that it's tied to a Discord role? If so, I don't think it'd be possible to make it case insensitive as Discord roles are case sensitive.

RheingoldRiver commented 1 year ago

no this isnt tied to discord role, this is the "Key" from the first line.

this pr requires one of the following:

  1. adding like a keylc in the config and then lowercasing the key the user gives and comparing those two things
  2. on user input iterating through all available keys and checking if the lower(key) == lower(user input)
  3. writing a script to lowercase every single existing key in the config and then not actually knowing what the key was. for UX you could just spit back Key: Whatever the user gave as input instead of Key: Whatever you have saved (which is clearly lowercase and likely not what the user actually wants). This is still a little confusing cos the user might be like "what the fuck? didn't I enter a different case before?" and be like ".......? what is GOING ON?" but I think they'd get the idea pretty quick that we're case insensitive. Although, probably spitting back the all-lowercase version is prob better than spitting back user-input.

All 3 of these obviously have their merits; (1) and (2) are more user-friendly than (3), (2) takes longer to run while (1) requires more storage. However with the amount of data present (1) and (2) are both negligible (I mean literally completely irrelevant) in this case. That said I do prefer cleaner code so while I don't care about the computational overhead I do slightly prefer to not have the code complexity overhead of (1) or (2).

So, if you can figure out how to write a script to implement (3) that would be the preference. To add sample data use ^aep add and then maybe copy-paste the config you generated to another fake server to make sure what you're running gets it right when there's multiple servers; the config file location is in. There's a python json library that you'll want to use.

That said, if you can't figure this out, feel free to do 1 or 2. I think 1 is probably a slightly nicer implementation, but 2 is probably the easiest, and having any implementation is better than none. For (1) I'm not actually sure if you would need to write a script to populate existing keys or if Red will auto-do this for you, you'll need to check this. Or ask Aradia.

Where to find the data for the cogs: For me it's at

C:\Users\River\AppData\Local\Red-DiscordBot\Red-DiscordBot\data\Namitest\cogs