Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: "npm"
directory: "/hirpc"
schedule:
interval: "weekly"
interval: "quarterly"
open-pull-requests-limit: 10
labels:
- "scope:hirpc"
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/hirpc-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ name: hiRPC Resources
on:
pull_request:
branches:
- dev
types: [labeled]
- main
paths:
- "hirpc/**/*.json"
- "hirpc/**/*.js"
- "hirpc/**/*.ts"
types:
- opened
- labeled
- synchronize

jobs:
hirpc_build:
if: contains(github.event.label.name, 'ci:ready')
if: contains(join(github.event.pull_request.labels.*.name, ','), 'ci:ready')
name: hiRPC Build
runs-on: ubuntu-latest
defaults:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hirpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: hiRPC
on:
push:
branches:
- dev
- main
paths:
- "hirpc/**/*.json"
- "hirpc/**/*.js"
- "hirpc/**/*.ts"
pull_request:
branches:
- dev
- main
paths:
- "hirpc/**/*.json"
- "hirpc/**/*.js"
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/unity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ name: Unity
on:
push:
branches:
- dev
- main
paths:
- "unity/**/*.cs"
pull_request:
branches:
- dev
- main
paths:
- "unity/**/*.cs"
types:
- opened
- labeled
- synchronize

jobs:
unity_tests:
if: >
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
contains(join(github.event.pull_request.labels.*.name, ','), 'ci:ready'))
name: Unity Tests
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Website

# For development, the site will be updated on pushes to the dev branch.

on:
push:
branches:
- dev
- main
paths:
- "website/**/*.ts"
- "website/**/*.tsx"
Expand Down
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ We recommend using [Conventional Commits](https://www.conventionalcommits.org/en
<td>✅</td>
<td></td>
</tr>
<tr>
<td>/examples</td>
<td>Code samples and basic backend.</td>
<td>Contributions are accepted. Open an issue to discuss new examples.</td>
<td>✅</td>
<td></td>
</tr>
<tr>
<td>/website</td>
<td>Site that hosts documentation and guides.</td>
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

> [!NOTE]
> Looking for version 1? See the [v1 branch](https://github.com/Furnyr/Dissonity/tree/v1).

<div align="center">
<a href="https://dissonity.dev" alt="a"><img src="https://i.imgur.com/AmGkPpE.png" width="650"></a>
</div>
Expand Down
6 changes: 6 additions & 0 deletions hirpc-kit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this package will be documented in this file.

## [0.1.4] - 2025-05-30

### Added

- Added the HiRpcShape type to the exports.

## [0.1.3] - 2025-04-12

### Changed
Expand Down
2 changes: 1 addition & 1 deletion hirpc-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dissonity/hirpc-kit",
"version": "0.1.3",
"version": "0.1.4",
"description": "Types and utilities for the Dissonity hiRPC",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
1 change: 1 addition & 0 deletions hirpc-kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HiRpcShape } from "./types";
export { HiRpcShape };

// import type { Opcode } from "../types/enums";
export enum RpcOpcode {
Expand Down
14 changes: 14 additions & 0 deletions unity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this package will be documented in this file.

## [2.0.1] - 2025-05-30

### Added

- Added link.xml to the Dissonity folder. This fixes stripping issues in some Unity versions.

### Changed

- Updated the mock return data of `Api.Commands.ShareLink`.

### Fixed

- `Api.GuildId` is now nullable, since it has a null value in DMs.

## [2.0.0] - 2025-04-15

Compared to `v2.0.0-beta.2`:
Expand Down
13 changes: 12 additions & 1 deletion unity/Editor/AddTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ static void ExecuteProcess(string[] _importedAssets, string[] _deletedAssets, st

// Target where the WebGL Template should be
string targetPath = CombinePath(Application.dataPath, "WebGLTemplates/Dissonity");
string metaTargetPath = CombinePath(Application.dataPath, "WebGLTemplates/Dissonity.meta");

//# ASSETS/DISSONITY - - - - -
string pathToFolder = CombinePath(Application.dataPath, "Dissonity");
string pathToDialogs = CombinePath(pathToFolder, "Dialogs.asset");
string pathToLink = CombinePath(pathToFolder, "link.xml");

// If Assets/Dissonity doesn't exist, create it.
if (!Directory.Exists(pathToFolder))
Expand All @@ -66,6 +66,17 @@ static void ExecuteProcess(string[] _importedAssets, string[] _deletedAssets, st
AssetDatabase.CreateAsset(asset, relativePathToDialogs);
}

// If Assets/Dissonity/link.xml doesn't exist, create it.
if (!File.Exists(pathToLink))
{
//\ Create link file
string fileText = Loady.Load<TextAsset>("Link.txt").text;

File.WriteAllText(pathToLink, fileText);

AssetDatabase.Refresh();
}

//# WEBGL TEMPLATE - - - - -
string pathToTemplates = CombinePath(Application.dataPath, "WebGLTemplates");

Expand Down
3 changes: 3 additions & 0 deletions unity/Editor/Assets/Link.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<linker>
<assembly fullname="Furnyr.Dissonity" preserve="all"/>
</linker>
7 changes: 7 additions & 0 deletions unity/Editor/Assets/Link.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 7 additions & 30 deletions unity/Editor/Dialogs/UpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,51 +44,39 @@ private void OnGUI()
GUILayout.Space(10);
GUILayout.BeginVertical();

GUILayout.Label("v1-v2.0.0 Overview", headerStyle);
GUILayout.Label("v2.0.1 Overview", headerStyle);

GUILayout.Label("Overhauled, improved and extended SDK.", centerStyle);
GUILayout.Label("Bug fixes", centerStyle);

GUILayout.Space(15);

GUILayout.Label("Added", subHeaderStyle);

GUILayout.Space(10);

GUILayout.Label("- Dissonity.Api methods");
GUILayout.Label("- Dissonity.Api.Commands methods");
GUILayout.Label("- Dissonity.Api.Subscribe methods");
GUILayout.Label("- Dissonity.Api.LocalStorage methods");
GUILayout.Label("- Dissonity.Api.Proxy methods");
GUILayout.Label("- Dissonity.Api.HiRpc methods");
GUILayout.Label("- Dissonity.Utils methods");
GUILayout.Label("- Dissonity.Models classes");
GUILayout.Label("- @DiscordMock object");
GUILayout.Label("- @JavascriptMock object");
GUILayout.Label("- Added link.xml file to the Dissonity folder.");

GUILayout.Space(15);

GUILayout.Label("Changed", subHeaderStyle);

GUILayout.Space(10);

GUILayout.Label("- Playtest your Discord activity within Unity!");
GUILayout.Label("- Not limited to Node.js servers.");
GUILayout.Label("- You must call and await Api.Initialize once per runtime.");
GUILayout.Label("- Api.Commands.ShareLink returns a complete mock response.");

GUILayout.Space(15);

GUILayout.Label("Fixed", subHeaderStyle);

GUILayout.Space(10);

GUILayout.Label("- Fixed check to detect absolute urls in proxy requests.");
GUILayout.Label("- Added hiRPC mock runtime limitations.");
GUILayout.Label("- Api.GuildId is now nullable as it should be.");

GUILayout.Space(10);

GUILayout.Label("And more!", italicStyle);
//GUILayout.Label("And more!", italicStyle);

GUILayout.Space(20);
//GUILayout.Space(20);

if (GUILayout.Button("Got it!", GUILayout.Height(25)))
{
Expand All @@ -99,17 +87,6 @@ private void OnGUI()

GUILayout.Label("Links", subHeaderStyle);

//todo remove after initial release
if (EditorGUILayout.LinkButton("Full Alpha changelog"))
{
Application.OpenURL("https://github.com/Furnyr/Dissonity/blob/v2/.github/archive/ALPHA_CHANGELOG.md");
}

if (EditorGUILayout.LinkButton("Full Beta changelog"))
{
Application.OpenURL("https://github.com/Furnyr/Dissonity/blob/v2/.github/archive/BETA_CHANGELOG.md");
}

if (EditorGUILayout.LinkButton("Documentation"))
{
Application.OpenURL("https://dissonity.dev");
Expand Down
4 changes: 4 additions & 0 deletions unity/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

> [!NOTE]
> Looking for version 1? See the [v1 branch](https://github.com/Furnyr/Dissonity/tree/v1).

<div align="center">
<a href="https://dissonity.dev" alt="a"><img src="https://i.imgur.com/AmGkPpE.png" width="650"></a>
</div>
Expand Down
20 changes: 11 additions & 9 deletions unity/Runtime/DissonityApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static class Api
internal static long? _clientId;
internal static string? _instanceId;
internal static string? _platform;
internal static long? _guildId;
internal static long? _guildId = null;
internal static long? _channelId;
internal static long? _userId = null;
internal static string? _accessToken = null;
Expand Down Expand Up @@ -113,17 +113,17 @@ public static string Platform
}

/// <summary>
/// <c> ❄️ </c> The id of the guild on which the activity is running.
/// <c> ❄️ </c> The id of the guild on which the activity is running. Returns null if the activity runs in a DM.
/// </summary>
public static long GuildId
public static long? GuildId
{
get
{
if (!_ready) throw new InvalidOperationException("You can't access this property before waiting for Api.Initialize");

if (_mock) return GameObject.FindAnyObjectByType<DiscordMock>()._query.GuildId;

return (long) _guildId!;
return _guildId;
}
}

Expand Down Expand Up @@ -1002,8 +1002,8 @@ public static async Task<ShareLinkData> ShareLink(string message, string? custom

return response.Data;
}
//todo This seems to depend on a scope that needs Discord approval, and the command itself is undocumented. I am leaving this method as private because I can't test it properly.

//todo This is now documented and can be released in the next minor update.
/// <summary>
/// Available in the official SDK but not documented in https://discord.com/developers/docs/developer-tools/embedded-app-sdk
/// </summary>
Expand All @@ -1020,7 +1020,7 @@ private static async Task<Relationship[]> GetRelationships()
return mockResponse.Data.Relationships;
}

var response = await SendCommand<GetRelationships, GetRelationshipsResponse>(new ());
var response = await SendCommand<GetRelationships, GetRelationshipsResponse>(new());

return response.Data.Relationships;
}
Expand Down Expand Up @@ -2536,7 +2536,7 @@ await Subscribe.SubscribeCommandFactory<CurrentUserUpdate, User>(data =>
}

//? Synchronize guild member RPC
if (_configuration!.SynchronizeGuildMemberRpc)
if (_configuration!.SynchronizeGuildMemberRpc && _guildId != null)
{
//? Invalid scopes
if (!_configuration!.OauthScopes.Contains(OauthScope.Identify) || !_configuration!.OauthScopes.Contains(OauthScope.GuildsMembersRead))
Expand Down Expand Up @@ -2894,7 +2894,9 @@ private static Task<TResponse> MockSendCommand<TResponse>(object? arg = null) wh

response.Data = new()
{
Success = true
Success = true,
DidCopyLink = true,
DidSendMessage = true
};

((TaskCompletionSource<ShareLinkResponse>) (object) tcs).TrySetResult(response);
Expand Down
2 changes: 1 addition & 1 deletion unity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.furnyr.dissonity",
"version": "2.0.0",
"version": "2.0.1",
"unity": "2021.3",
"displayName": "Dissonity",
"description": "Interact with the Discord client inside a Unity activity.",
Expand Down
8 changes: 4 additions & 4 deletions website/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const COPY_BUTTON_PADDING = "10px";
export const COPY_BUTTON_PADDING_MOBILE = "8.5px";
export const GITHUB_LINK = "https://github.com/Furnyr/Dissonity/tree/v2";
export const GITHUB_LINK = "https://github.com/Furnyr/Dissonity/";
export const GITHUB_NODE_LINK = "https://github.com/Furnyr/Dissonity-Examples/tree/main/basic-node-server";
export const GITHUB_CONTRIBUTORS_LINK = "https://github.com/Furnyr/Dissonity/blob/v2/CONTRIBUTING.md";
export const GITHUB_FILE_EXAMPLES_LINK = "https://github.com/Furnyr/Dissonity/tree/v2/examples/files";
export const GITHUB_LOCAL_AUTOMATION_LINK = "https://github.com/Furnyr/Dissonity/tree/v2/local-automation";
export const GITHUB_CONTRIBUTORS_LINK = "https://github.com/Furnyr/Dissonity/blob/main/CONTRIBUTING.md";
export const GITHUB_FILE_EXAMPLES_LINK = "https://github.com/Furnyr/Dissonity-Examples/tree/main/files";
export const GITHUB_LOCAL_AUTOMATION_LINK = "https://github.com/Furnyr/Dissonity/tree/main/local-automation";
export const DEFAULT_TITLE = "Dissonity - Create Discord activities with Unity";
2 changes: 1 addition & 1 deletion website/src/routes/docs/internals/hirpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ main();`}</CodeBlock>
<i>Example index.ts using @dissonity/hirpc-kit</i>

<p>
You can find further examples in the repository's <a href={GITHUB_FILE_EXAMPLES_LINK} target="_blank">examples folder</a>.
You can find further examples in the example repository's <a href={GITHUB_FILE_EXAMPLES_LINK} target="_blank">files folder</a>.
</p>

<h2 id="final-terminology">Final Terminology <HashLink link="/?/docs/v2/internals/hirpc#final-terminology" /></h2>
Expand Down