1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsValue;

#[wasm_bindgen(module = "@discord/embedded-app-sdk")]
extern "C" {
    #[wasm_bindgen(extends=js_sys::Object)]
    pub type DiscordSDK;

    #[wasm_bindgen(constructor, catch)]
    pub fn new(clientId: &str) -> Result<DiscordSDK, JsValue>;

    #[wasm_bindgen(method, getter, js_name = clientId)]
    pub fn client_id(this: &DiscordSDK) -> String;

    #[wasm_bindgen(method, getter, js_name = instanceId)]
    pub fn instance_id(this: &DiscordSDK) -> String;

    #[wasm_bindgen(method, getter)]
    pub fn platform(this: &DiscordSDK) -> String;

    #[wasm_bindgen(method, getter, js_name = guildId)]
    pub fn guild_id(this: &DiscordSDK) -> Option<String>;

    #[wasm_bindgen(method, getter, js_name = channelId)]
    pub fn channel_id(this: &DiscordSDK) -> Option<String>;

    #[wasm_bindgen(method, getter)]
    pub fn configuration(this: &DiscordSDK) -> JsValue;

    #[wasm_bindgen(method, getter)]
    pub fn commands(this: &DiscordSDK) -> DiscordSDKCommands;

    #[wasm_bindgen(method, catch)]
    pub async fn ready(this: &DiscordSDK) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch)]
    pub async fn subscribe(
        this: &DiscordSDK,
        event: &str,
        f: &Closure<dyn FnMut(JsValue) -> Result<(), JsValue>>,
        args: JsValue,
    ) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch)]
    pub async fn unsubscribe(this: &DiscordSDK, event: &str) -> Result<(), JsValue>;

    #[wasm_bindgen(method, js_name = unsubscribe)]
    pub fn unsubscribe_nowait(this: &DiscordSDK, event: &str);
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=js_sys::Object)]
    pub type DiscordSDKCommands;

    #[wasm_bindgen(method, catch)]
    pub async fn authorize(this: &DiscordSDKCommands, args: JsValue) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch)]
    pub async fn authenticate(this: &DiscordSDKCommands, args: JsValue)
        -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = captureLog)]
    pub async fn capture_log(this: &DiscordSDKCommands, args: JsValue) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = encourageHardwareAcceleration)]
    pub async fn encourage_hardware_acceleration(this: &DiscordSDKCommands) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = getChannel)]
    pub async fn get_channel(this: &DiscordSDKCommands, args: JsValue) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = getChannelPermissions)]
    pub async fn get_channel_permissions(this: &DiscordSDKCommands) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = getInstanceConnectedParticipants)]
    pub async fn get_instance_connected_participants(
        this: &DiscordSDKCommands,
    ) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = getPlatformBehaviors)]
    pub async fn get_platform_behaviors(this: &DiscordSDKCommands) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = initiateImageUpload)]
    pub async fn initiate_image_upload(this: &DiscordSDKCommands) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = openExternalLink)]
    pub async fn open_external_link(
        this: &DiscordSDKCommands,
        args: JsValue,
    ) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = openInviteDialog)]
    pub async fn open_invite_dialog(this: &DiscordSDKCommands) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = openShareMomentDialog)]
    pub async fn open_share_moment_dialog(
        this: &DiscordSDKCommands,
        args: JsValue,
    ) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = setActivity)]
    pub async fn set_activity(this: &DiscordSDKCommands, args: JsValue) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = setConfig)]
    pub async fn set_config(this: &DiscordSDKCommands, args: JsValue) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = setOrientationLockState)]
    pub async fn set_orientation_lock_state(
        this: &DiscordSDKCommands,
        args: JsValue,
    ) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = userSettingsGetLocale)]
    pub async fn user_settings_get_locale(this: &DiscordSDKCommands) -> Result<JsValue, JsValue>;
}