Cogmasters / concord

A Discord API wrapper library made in C
https://cogmasters.github.io/concord/
MIT License
523 stars 30 forks source link

Pass additional data to callbacks #177

Closed SoujiThenria closed 6 months ago

SoujiThenria commented 6 months ago

Describe the feature

Pass additional data (e.g. database handle) to callbacks triggered on events.

For example, for discord_set_on_interaction_create and alike, it would be nice to be able to pass additional data without using a global variable, but using something like this:

void discord_set_on_interaction_create(struct discord *client, void (*callback)(struct discord *, const struct discord_interaction *), void *data)

Version

concord version: 769bdb74b066b2f250a3ec9199063532e4dcccf2

LSB Version: 1.0 Distributor ID: VoidLinux Description: Void Linux Release: rolling Codename: void

ThePedroo commented 6 months ago

Maybe what you are looking is discord_set_data? This allows to set a variable that is accessible from anywhere where you have access to Concord client

SoujiThenria commented 6 months ago

Oh, you are right; this looks exactly like what I was looking for. Thank you.