The Wayback Machine - https://web.archive.org/web/20220430113238/https://github.com/discord/discord-api-docs/issues/1502
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK starter guide lacks important details #1502

Open
bugproof opened this issue Apr 12, 2020 · 2 comments
Open

SDK starter guide lacks important details #1502

bugproof opened this issue Apr 12, 2020 · 2 comments

Comments

@bugproof
Copy link

@bugproof bugproof commented Apr 12, 2020

Application below will crash if discord is not running or is not installed. core will be null. The docs should mention that. (when using NoRequireDiscord)

if (core) should be added before updating activity.

https://discordapp.com/developers/docs/game-sdk/sdk-starter-guide

#include "MyPawn.h"
#include "discord-files/discord.h"

discord::Core* core{};

AMyPawn::AMyPawn()
{
     // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void AMyPawn::BeginPlay()
{
    Super::BeginPlay();
    /*
        Grab that Client ID from earlier
        Discord.CreateFlags.Default will require Discord to be running for the game to work
        If Discord is not running, it will:
        1. Close your game
        2. Open Discord
        3. Attempt to re-open your game
        Step 3 will fail when running directly from the Unity editor
        Therefore, always keep Discord running during tests, or use Discord.CreateFlags.NoRequireDiscord
    */
    auto result = discord::Core::Create(461618159171141643, DiscordCreateFlags_Default, &core);
    discord::Activity activity{};
    activity.SetState("Testing");
    activity.SetDetails("Fruit Loops");
    core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {

    });
}

// Called every frame
void AMyPawn::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    ::core->RunCallbacks();
}

// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);
}
@night
Copy link

@night night commented Apr 13, 2020

I've marked this as documentation needed, but pull requests are welcome.

@PixelNinja132
Copy link

@PixelNinja132 PixelNinja132 commented Apr 25, 2020

I think it also needs this for dispatch, it is not clear at all, without directly asking Mason, I would not have been able to do it, even aster scanning the docs for weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.