You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to play sounds from an external API call (Soundboard)
But I can't get the songbird instance
I tried storing it in a lazy_static but since it doesn't implement the Send trait I cant?
The bot is only on one server, so any hack/workaround is working for me
Any luck or is it not possible?
The text was updated successfully, but these errors were encountered:
It should be possible to store the Arc<Songbird> instance within lazy_static. I use this to have it accessible in a different thread than where I initialize it:
I use a OnceCell here as it allows us to set the value once after it has been initialized. We do not require setting the variable more than once after its initialization, so this is perfect.
If you are using serenity, and want to know how to set this after initializing the client, its as follows:
let sb = client.data.read().await.get::<SongbirdKey>().expect("Failed to get or initialize Songbird").clone();SONG.set(sb).expect("Error setting Songbird (SONG)");
Then, to use it anywhere in your code, all you need to do is:
let sb = SONG.get().expect("Songbird not found!").clone();
I want to play sounds from an external API call (Soundboard)
But I can't get the songbird instance
I tried storing it in a lazy_static but since it doesn't implement the Send trait I cant?
The bot is only on one server, so any hack/workaround is working for me
Any luck or is it not possible?
The text was updated successfully, but these errors were encountered: