Bilal2453 / discordia-interactions

A Discordia library extension that enables receiving and responding to Discord's Interactions.
Apache License 2.0
21 stars 5 forks source link

Maybe use simpler control flow #1

Closed Plecra closed 2 years ago

Plecra commented 3 years ago

https://github.com/Bilal2453/discordia-interactions/blob/bb4c13d6ccbf457bdea8b2aa06ce35710038c90b/libs/containers/Interaction.lua#L29

Could this be replaced with a normal if?

Bilal2453 commented 3 years ago

It could be replaced with a normal if statement indeed. But for the same reason continue labels in for loops are being used — Even though they could be replaced with an if statement — this is used here. Quite the cleaner look compared to a bigger if statement, although this is not a bad suggestion so I will be considering simplifying and refactoring many of those code blocks sometime in the future once this is fully released.

On Fri, 29 Oct 2021, 00:39 Plecra, @.***> wrote:

https://github.com/Bilal2453/discordia-interactions/blob/bb4c13d6ccbf457bdea8b2aa06ce35710038c90b/libs/containers/Interaction.lua#L29

Could this be replaced with a normal if?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Bilal2453/discordia-interactions/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDIIYDBZJU7OFXPTYO4G7TUJHGLXANCNFSM5G54JGGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Bilal2453 commented 2 years ago

The last commits should've simplified control-flow a bit, sadly I can't see myself using if statements here, it would complicate a lot of the things. I as well don't see myself moving each of those blocks into a function, that is obsolete.

Perhaps, there is a better way I am missing, until that suggestions are welcomed.