Dissonity
Unity SDK for Discord activities
Loading...
Searching...
No Matches
Dissonity.Api Class Reference

Classes

class  Commands
 Subclass that allows sending RPC commands. More...
 
class  HiRpc
 Subclass that enables C#/JS interoperation. More...
 
class  LocalStorage
 Subclass that allows storing key-value pairs locally. More...
 
class  Proxy
 Subclass that helps sending HTTPs requests through the Discord proxy. More...
 
class  Subscribe
 Subclass that allows listening to RPC events. More...
 

Static Public Member Functions

static Task< MultiEventInitialize ()
 Initializes Dissonity. You must call and await this method once before doing anything else.
 
static async Task< bool > OnReady ()
 Use this method to wait for initialization to complete.

Returns true if the game is executed inside Discord.
 
static Task PatchUrlMappings (MappingBuilder[] mappings, PatchUrlMappingsConfigBuilder? config=null)
 Use this method to easily access external resources.

If you need to use it before initialization, consider using Mappings and PatchUrlMappingsConfig from the DissonityConfig instead.

https://discord.com/developers/docs/activities/development-guides#using-external-resources.
 
static Task< string > FormatPrice (SkuPrice price, string locale=Locale.UsEnglish)
 Use this method to easily render SKU prices. When called in the Unity Editor, uses a generic currency symbol ¤ .
 
static void Unsubscribe (DiscordSubscription reference)
 Remove a subscription via a DiscordSubscription instance (returned by subscription methods).
 
static void Unsubscribe< T > (Action< T > listener)
 Remove a subscription via the event return data type and a method.
 
static void UnsubscribeFromEvent (string eventString)
 Remove all subscriptions related to a single event.
 
static void ClearAllSubscriptions ()
 Remove all subscriptions from every event.
 
static void Close (RpcCloseCode code, string message="")
 Close the app with a specified code and reason.
 

Static Public Attributes

const string ProxyDomain = "discordsays.com"
 

Properties

static long ClientId [get]
  ❄️ Your app's client id.
 
static string InstanceId [get]
 Unique string id for each activity instance.
 
static string Platform [get]
 The platform on which the activity is running. It's a value of Models.Platform .
 
static ? long GuildId [get]
  ❄️ The id of the guild on which the activity is running. Returns null if the activity runs in a DM.
 
static long ChannelId [get]
  ❄️ The id of the channel on which the activity is running.
 
static string FrameId [get]
 The activity frame id.
 
static ? string MobileAppVersion [get]
 The mobile client version. Returns null in desktop.
 
static string CustomId [get]
 Query custom id. Used when a user joins the activity via a shared link.
 
static string ReferrerId [get]
 Query referrer id. Used when a user joins the activity via a shared link.
 
static string LocationId [get]
 Query location id.
 
static ? long UserId [get]
  ❄️ The current user id.
 
static string AccessToken [get]
 Your client access token.

⚠️ This is highly-sensitive data. Handle this token securely and don't expose it. Use encryption if you need it outside of Unity.
 
static string ApplicationAccessHash [get]
 Your hiRPC application access hash.

⚠️ This allows access to restricted hiRPC functionality. Handle it securely.
 
static bool Initialized [get]
 True after the first Api.Initialize call, regardless of success.
 
static bool Ready [get]
 True if the Api.Initialize call was successful.
 
static ? User SyncedUser [get]
 If SynchronizeUser is enabled in the config, returns the current user object.
 
static ? GuildMemberRpc SyncedGuildMemberRpc [get]
 If SynchronizeGuildMemberRpc is enabled in the config, returns the current guild member RPC object.
 
static ISdkConfiguration Configuration [get]
 
static bool IsMock [get]
 

Member Function Documentation

◆ ClearAllSubscriptions()

static void Dissonity.Api.ClearAllSubscriptions ( )
inlinestatic

Remove all subscriptions from every event.

Exceptions
InvalidOperationException

◆ Close()

static void Dissonity.Api.Close ( RpcCloseCode code,
string message = "" )
inlinestatic

Close the app with a specified code and reason.

Exceptions
InvalidOperationException

◆ FormatPrice()

static Task< string > Dissonity.Api.FormatPrice ( SkuPrice price,
string locale = Locale::UsEnglish )
inlinestatic

Use this method to easily render SKU prices. When called in the Unity Editor, uses a generic currency symbol ¤ .

Exceptions
InvalidOperationException

◆ Initialize()

static Task< MultiEvent > Dissonity.Api.Initialize ( )
inlinestatic

Initializes Dissonity. You must call and await this method once before doing anything else.

Exceptions
InvalidOperationException
OutsideDiscordException
ExternalException
JsonException
ArgumentException

◆ OnReady()

static async Task< bool > Dissonity.Api.OnReady ( )
inlinestatic

Use this method to wait for initialization to complete.

Returns true if the game is executed inside Discord.

◆ PatchUrlMappings()

static Task Dissonity.Api.PatchUrlMappings ( MappingBuilder[] mappings,
PatchUrlMappingsConfigBuilder? config = null )
inlinestatic

Use this method to easily access external resources.

If you need to use it before initialization, consider using Mappings and PatchUrlMappingsConfig from the DissonityConfig instead.

https://discord.com/developers/docs/activities/development-guides#using-external-resources.

Exceptions
InvalidOperationException

◆ Unsubscribe()

static void Dissonity.Api.Unsubscribe ( DiscordSubscription reference)
inlinestatic

Remove a subscription via a DiscordSubscription instance (returned by subscription methods).

Exceptions
InvalidOperationException
ArgumentException

◆ Unsubscribe< T >()

static void Dissonity.Api.Unsubscribe< T > ( Action< T > listener)
inlinestatic

Remove a subscription via the event return data type and a method.

Exceptions
InvalidOperationException
ArgumentException

◆ UnsubscribeFromEvent()

static void Dissonity.Api.UnsubscribeFromEvent ( string eventString)
inlinestatic

Remove all subscriptions related to a single event.

Exceptions
InvalidOperationException

Member Data Documentation

◆ ProxyDomain

const string Dissonity.Api.ProxyDomain = "discordsays.com"
static

Property Documentation

◆ AccessToken

string Dissonity.Api.AccessToken
staticget

Your client access token.

⚠️ This is highly-sensitive data. Handle this token securely and don't expose it. Use encryption if you need it outside of Unity.

◆ ApplicationAccessHash

string Dissonity.Api.ApplicationAccessHash
staticget

Your hiRPC application access hash.

⚠️ This allows access to restricted hiRPC functionality. Handle it securely.

◆ ChannelId

long Dissonity.Api.ChannelId
staticget

❄️ The id of the channel on which the activity is running.

◆ ClientId

long Dissonity.Api.ClientId
staticget

❄️ Your app's client id.

◆ Configuration

ISdkConfiguration Dissonity.Api.Configuration
staticget

◆ CustomId

string Dissonity.Api.CustomId
staticget

Query custom id. Used when a user joins the activity via a shared link.

◆ FrameId

string Dissonity.Api.FrameId
staticget

The activity frame id.

◆ GuildId

? long Dissonity.Api.GuildId
staticget

❄️ The id of the guild on which the activity is running. Returns null if the activity runs in a DM.

◆ Initialized

bool Dissonity.Api.Initialized
staticget

True after the first Api.Initialize call, regardless of success.

◆ InstanceId

string Dissonity.Api.InstanceId
staticget

Unique string id for each activity instance.

◆ IsMock

bool Dissonity.Api.IsMock
staticget

◆ LocationId

string Dissonity.Api.LocationId
staticget

Query location id.

◆ MobileAppVersion

? string Dissonity.Api.MobileAppVersion
staticget

The mobile client version. Returns null in desktop.

◆ Platform

string Dissonity.Api.Platform
staticget

The platform on which the activity is running. It's a value of Models.Platform .

◆ Ready

bool Dissonity.Api.Ready
staticget

True if the Api.Initialize call was successful.

◆ ReferrerId

string Dissonity.Api.ReferrerId
staticget

Query referrer id. Used when a user joins the activity via a shared link.

◆ SyncedGuildMemberRpc

? GuildMemberRpc Dissonity.Api.SyncedGuildMemberRpc
staticget

If SynchronizeGuildMemberRpc is enabled in the config, returns the current guild member RPC object.

◆ SyncedUser

? User Dissonity.Api.SyncedUser
staticget

If SynchronizeUser is enabled in the config, returns the current user object.

◆ UserId

? long Dissonity.Api.UserId
staticget

❄️ The current user id.


The documentation for this class was generated from the following file: