[Feature] Expose GetCurrentUser method & missing current user API methods (#2574)
* add stuff * forgot to push * docs * Update DiscordRestClient.cs * Apply suggestions from code review * Update toc.yml --------- Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>
This commit is contained in:
11
docs/guides/bearer_token/samples/app_role_connection.cs
Normal file
11
docs/guides/bearer_token/samples/app_role_connection.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
// fetch application role connection of the current user for the app with provided id.
|
||||
var roleConnection = await client.GetUserApplicationRoleConnectionAsync(applicationid);
|
||||
|
||||
// create a new role connection metadata properties object & set some values.
|
||||
var properties = new RoleConnectionProperties("Discord.Net Docs", "Cool Coding Guy")
|
||||
.WithNumber("eaten_cookies", 69)
|
||||
.WithBool("loves_cookies", true)
|
||||
.WithDate("last_eaten_cookie", DateTimeOffset.UtcNow);
|
||||
|
||||
// update current user's values with the given properties.
|
||||
await client.ModifyUserApplicationRoleConnectionAsync(applicationId, properties);
|
||||
5
docs/guides/bearer_token/samples/current_user.cs
Normal file
5
docs/guides/bearer_token/samples/current_user.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
// gets the user object stored in the DiscordRestClient.
|
||||
var user = client.CurrentUser;
|
||||
|
||||
// fetches the current user with a REST call & updates the CurrentUser property.
|
||||
var refreshedUser = await client.GetCurrentUserAsync();
|
||||
@@ -0,0 +1,2 @@
|
||||
// fetches the current user's connections.
|
||||
var connections = await client.GetConnectionsAsync();
|
||||
@@ -0,0 +1,6 @@
|
||||
// fetches the current user's guild member object in a guild with provided id.
|
||||
var member = await client.GetCurrentUserGuildMemberAsync(guildId);
|
||||
|
||||
// fetches the current user's guild member object in a RestUserGuild.
|
||||
var guild = await client.GetGuildSummariesAsync().FlattenAsync().First();
|
||||
var member = await guild.GetCurrentUserGuildMemberAsync();
|
||||
2
docs/guides/bearer_token/samples/current_user_guilds.cs
Normal file
2
docs/guides/bearer_token/samples/current_user_guilds.cs
Normal file
@@ -0,0 +1,2 @@
|
||||
// fetches the guilds the current user participate in.
|
||||
var guilds = await client.GetGuildSummariesAsync().FlattenAsync();
|
||||
5
docs/guides/bearer_token/samples/rest_client_init.cs
Normal file
5
docs/guides/bearer_token/samples/rest_client_init.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using Discord;
|
||||
using Discord.Rest;
|
||||
|
||||
await using var client = new DiscordRestClient();
|
||||
await client.LoginAsync(TokenType.Bearer, "bearer token obtained through oauth2 flow");
|
||||
Reference in New Issue
Block a user