{"id":23132459,"url":"https://github.com/merlinfuchs/activities-rs","last_synced_at":"2025-08-17T08:32:26.973Z","repository":{"id":229828685,"uuid":"777399742","full_name":"merlinfuchs/activities-rs","owner":"merlinfuchs","description":"Write Discord Activities in 100% Rust via WebAssembly","archived":false,"fork":false,"pushed_at":"2024-03-28T11:46:51.000Z","size":160,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-10T14:19:37.923Z","etag":null,"topics":["activities","discord","rust","webassembly"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/activity","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/merlinfuchs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-25T19:28:03.000Z","updated_at":"2024-12-05T09:23:11.000Z","dependencies_parsed_at":"2024-03-26T13:58:00.071Z","dependency_job_id":null,"html_url":"https://github.com/merlinfuchs/activities-rs","commit_stats":null,"previous_names":["merlinfuchs/activity-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlinfuchs%2Factivities-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlinfuchs%2Factivities-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlinfuchs%2Factivities-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlinfuchs%2Factivities-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merlinfuchs","download_url":"https://codeload.github.com/merlinfuchs/activities-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230106056,"owners_count":18173987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activities","discord","rust","webassembly"],"created_at":"2024-12-17T11:18:50.338Z","updated_at":"2025-08-17T08:32:26.964Z","avatar_url":"https://github.com/merlinfuchs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# activities-rs\n\nErgonomic Rust bindings to the [Discord Embedded App SDK](https://github.com/discord/embedded-app-sdk).\n\n## Features\n\nCurrently bundled SDK version: `1.9.0`.\n\n- [x] Support for all commands\n- [x] Support for all events\n- [x] No JS required\n\n## Example Usage\n\n```rust\nuse activity::*;\nuse std::{mem::forget, option_env};\n\n#[activity]\npub async fn start() -\u003e Result\u003c(), JsValue\u003e {\n    console_log!(\"Starting activity...\");\n\n    let client_id = option_env!(\"CLIENT_ID\").expect(\"CLIENT_ID environment variable must be set\");\n    let sdk = DiscordSDK::new(client_id)?;\n    sdk.ready().await?;\n\n    console_log!(\"Activity ready!\");\n\n    authenticate_user(\u0026sdk).await?;\n\n    let s = sdk\n        .subscribe(\n            |e: VoiceStateUpdateEvent| {\n                console_log!(\"Voice state update: {:?}\", e);\n                Ok(())\n            },\n            SubscribeArgs::channel_id(sdk.channel_id().unwrap()),\n        )\n        .await?;\n\n    // When the subscription is dropped, the event will be unsubscribed\n    forget(s);\n\n    Ok(())\n}\n\nasync fn authenticate_user(sdk: \u0026DiscordSDK) -\u003e Result\u003c(), JsValue\u003e {\n    let res = sdk\n        .authorize(AuthorizeCommandArgs {\n            client_id: sdk.client_id(),\n            response_type: \"code\".to_string(),\n            state: \"\".to_string(),\n            prompt: \"none\".to_string(),\n            scope: vec![\n                \"identify\".to_string(),\n                \"guilds\".to_string(),\n                \"rpc.voice.read\".to_string(),\n            ],\n        })\n        .await?;\n\n    // The token exchange must happen through your own server. Implement this yourself!\n    let access_token = exchange_token(\u0026res.code).await?;\n\n    let res = sdk\n        .authenticate(AuthenticateCommandArgs { access_token })\n        .await?;\n\n    console_log!(\"Authenticated user: {:?}\", res.user);\n\n    Ok(())\n}\n```\n\n## Compiling an Activity\n\nThere is a build tool that makes it really easy to compile and bundle Rust activities. The finished bundle will be located in `build/activity`.\n\nAlternatively you can also use webpack with the wasm-pack plugin. See the [webpack example](examples/webpack).\n\n```shell\n# Install the build tool\ncargo install activity-build\n\n# Set env vars\nexport CLIENT_ID=1234567890\n\n# Run it in the directory where your `Cargo.toml` is located\nactivity-build --release\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerlinfuchs%2Factivities-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerlinfuchs%2Factivities-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerlinfuchs%2Factivities-rs/lists"}