Ejemplo n.º 1
0
        /// <summary>
        ///     Fetches the current member from a guild tied to this bearer token.
        /// </summary>
        /// <param name="client"> The bearer client. </param>
        /// <param name="guildId"> The ID of the guild to fetch the member from. </param>
        /// <param name="options"> The optional request options. </param>
        /// <param name="cancellationToken"> The cancellation token to observe. </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> representing the asynchronous request
        ///     that wraps the returned <see cref="IMember"/>.
        /// </returns>
        public static async Task <IMember> FetchCurrentGuildMemberAsync(this IBearerClient client,
                                                                        Snowflake guildId,
                                                                        IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var model = await client.RestClient.ApiClient.FetchCurrentGuildMemberAsync(guildId, options, cancellationToken).ConfigureAwait(false);

            return(new TransientMember(client.RestClient, guildId, model));
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Fetches the guilds of the user tied to this bearer token.
 /// </summary>
 /// <param name="client"> The bearer client. </param>
 /// <param name="limit"> The amount of guilds to fetch. </param>
 /// <param name="retrievalDirection"> The direction to fetch the guilds in. </param>
 /// <param name="startFromId"> The ID of the guild to start fetching from. </param>
 /// <param name="options"> The optional request options. </param>
 /// <param name="cancellationToken"> The cancellation token to observe. </param>
 /// <returns>
 ///     A <see cref="Task{TResult}"/> representing the asynchronous request
 ///     that wraps the returned <see cref="IReadOnlyList{T}"/> of <see cref="IPartialGuild"/>.
 /// </returns>
 public static Task <IReadOnlyList <IPartialGuild> > FetchGuildsAsync(this IBearerClient client,
                                                                      int limit = Discord.Limits.Rest.FetchGuildsPageSize, RetrievalDirection retrievalDirection = RetrievalDirection.Before, Snowflake?startFromId = null,
                                                                      IRestRequestOptions options = null, CancellationToken cancellationToken = default)
 {
     return(client.RestClient.FetchGuildsAsync(limit, retrievalDirection, startFromId, options, cancellationToken));
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Enumerates the guilds of the user tied to this bearer token.
 /// </summary>
 /// <param name="client"> The bearer client. </param>
 /// <param name="limit"> The amount of guilds to enumerate. </param>
 /// <param name="retrievalDirection"> The direction to enumerate the guilds in. </param>
 /// <param name="startFromId"> The ID of the guild to start enumerating from. </param>
 /// <param name="options"> The optional request options. </param>
 /// <returns>
 ///     A paged enumerable yielding the requested guilds.
 /// </returns>
 public static IPagedEnumerable <IPartialGuild> EnumerateGuilds(this IBearerClient client,
                                                                int limit, RetrievalDirection retrievalDirection = RetrievalDirection.After, Snowflake?startFromId = null,
                                                                IRestRequestOptions options = null)
 {
     return(client.RestClient.EnumerateGuilds(limit, retrievalDirection, startFromId, options));
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Fetches authorization information for this bearer token.
        /// </summary>
        /// <param name="client"> The bearer client. </param>
        /// <param name="options"> The optional request options. </param>
        /// <param name="cancellationToken"> The cancellation token to observe. </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> representing the asynchronous request
        ///     that wraps the returned <see cref="IBearerAuthorization"/>.
        /// </returns>
        public static async Task <IBearerAuthorization> FetchCurrentAuthorizationAsync(this IBearerClient client,
                                                                                       IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var model = await client.RestClient.ApiClient.FetchCurrentAuthorizationAsync(options, cancellationToken).ConfigureAwait(false);

            return(new TransientBearerAuthorization(client.RestClient, model));
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Fetches the user tied to this bearer token.
 /// </summary>
 /// <param name="client"> The bearer client. </param>
 /// <param name="options"> The optional request options. </param>
 /// <param name="cancellationToken"> The cancellation token to observe. </param>
 /// <returns>
 ///     A <see cref="Task{TResult}"/> representing the asynchronous request
 ///     that wraps the returned <see cref="ICurrentUser"/>.
 /// </returns>
 public static Task <ICurrentUser> FetchCurrentUserAsync(this IBearerClient client,
                                                         IRestRequestOptions options = null, CancellationToken cancellationToken = default)
 {
     return(client.RestClient.FetchCurrentUserAsync(options, cancellationToken));
 }
Ejemplo n.º 6
0
        /// <summary>
        ///     Fetches the connections of the user tied to this bearer token.
        /// </summary>
        /// <param name="client"> The bearer client. </param>
        /// <param name="options"> The optional request options. </param>
        /// <param name="cancellationToken"> The cancellation token to observe. </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> representing the asynchronous request
        ///     that wraps the returned <see cref="IReadOnlyList{T}"/> of <see cref="IUserConnection"/>.
        /// </returns>
        public static async Task <IReadOnlyList <IUserConnection> > FetchConnectionsAsync(this IBearerClient client,
                                                                                          IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var models = await client.RestClient.ApiClient.FetchConnectionsAsync(options, cancellationToken).ConfigureAwait(false);

            return(models.ToReadOnlyList(client, (model, client) => new TransientUserConnection(client.RestClient, model)));
        }