-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (35 loc) · 1.34 KB
/
Program.cs
File metadata and controls
53 lines (35 loc) · 1.34 KB
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
using Valour.Sdk.Client;
using DotNetEnv;
Env.Load();
var token = Environment.GetEnvironmentVariable("TOKEN");
if (string.IsNullOrWhiteSpace(token))
{
Console.WriteLine("TOKEN is not set in the .env - Make sure its labeled .env and not something.env");
return;
}
var client = new ValourClient("https://api.valour.gg");
client.SetupHttpClient();
var loginResult = await client.InitializeUser(token);
if (!loginResult.Success)
{
Console.WriteLine($"Login Failed: {loginResult.Message}");
return;
}
Console.WriteLine($"Logged in as {client.Me.Name} (ID: {client.Me.Id})");
long planetId = 00000000000000000; //Put your planet id here. (Copy Id gives the id wrong, if you add +1 it should work. ex: 42439954653511680 -> 42439954653511681)
string inviteCode = ""; //Place the invite code here (just the end part). (If planet is Discoverable, this is not required.)
try
{
var joinResult = string.IsNullOrWhiteSpace(inviteCode)
? await client.PlanetService.JoinPlanetAsync(planetId)
: await client.PlanetService.JoinPlanetAsync(planetId, inviteCode);
if (!joinResult.Success)
{
Console.WriteLine($"Failed to join planet: {joinResult.Message}");
return;
}
Console.WriteLine($"Successfullly joined Planet.");
} catch (Exception ex)
{
Console.WriteLine($"Error while joining planet: {ex.Message}");
}