예제 #1
0
        public static Task <RoleJsonModel> ModifyRoleAsync(this IRestApiClient client, Snowflake guildId, Snowflake roleId, ModifyRoleJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ModifyRole, guildId, roleId);

            return(client.ExecuteAsync <RoleJsonModel>(route, content, options));
        }
예제 #2
0
        public Task DeleteResponseAsync(IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.DeleteInteractionResponseAsync(Interaction.ApplicationId, Interaction.Token, options));
        }
예제 #3
0
        public Task <IUserMessage> FetchAsync(Snowflake followupId, IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.FetchInteractionFollowupAsync(Interaction.ApplicationId, Interaction.Token, followupId, options));
        }
        public static Task <ThreadListJsonModel> FetchJoinedPrivateArchivedThreadsAsync(this IRestApiClient client,
                                                                                        Snowflake channelId, int limit = Discord.Limits.Rest.FetchThreadsPageSize, Snowflake?startFromId = null,
                                                                                        IRestRequestOptions options    = null, CancellationToken cancellationToken = default)
        {
            Guard.IsBetweenOrEqualTo(limit, 0, Discord.Limits.Rest.FetchThreadsPageSize);

            var queryParameters = new Dictionary <string, object>
            {
                ["limit"] = limit
            };

            if (startFromId != null)
            {
                queryParameters["before"] = startFromId.Value;
            }

            var route = Format(Route.Channel.ListJoinedPrivateArchivedThreads, queryParameters, channelId);

            return(client.ExecuteAsync <ThreadListJsonModel>(route, null, options, cancellationToken));
        }
예제 #5
0
        public Task <IUserMessage> FetchResponseAsync(IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.FetchInteractionResponseAsync(Interaction.ApplicationId, Interaction.Token, options));
        }
예제 #6
0
        public static Task <MemberJsonModel[]> FetchMembersAsync(this IRestApiClient client, Snowflake guildId, int limit = 1000, Snowflake?startFromId = null, IRestRequestOptions options = null)
        {
            if (limit < 1 || limit > 1000)
            {
                throw new ArgumentOutOfRangeException(nameof(limit));
            }

            var queryParameters = new Dictionary <string, object>(startFromId != null ? 2 : 1)
            {
                ["limit"] = limit
            };

            if (startFromId != null)
            {
                queryParameters["after"] = startFromId;
            }

            var route = Format(Route.Guild.GetMembers, queryParameters, guildId);

            return(client.ExecuteAsync <MemberJsonModel[]>(route, null, options));
        }
예제 #7
0
 public FetchJoinedPrivateArchivedThreadsPagedEnumerator(IRestClient client, Snowflake channelId, int limit, Snowflake?startFromId, IRestRequestOptions options = null)
     : base(client, limit, options)
 {
     _channelId   = channelId;
     _startFromId = startFromId;
 }
예제 #8
0
        public static Task <WelcomeScreenJsonModel> ModifyGuildWelcomeScreenAsync(this IRestApiClient client, Snowflake guildId, ModifyWelcomeScreenJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ModifyWelcomeScreen, guildId);

            return(client.ExecuteAsync <WelcomeScreenJsonModel>(route, content, options));
        }
예제 #9
0
        public static Task <GuildWidgetJsonModel> FetchGuildWidgetAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.GetWidgetSettings, guildId);

            return(client.ExecuteAsync <GuildWidgetJsonModel>(route, null, options));
        }
예제 #10
0
        public static Task SyncIntegrationAsync(this IRestApiClient client, Snowflake guildId, Snowflake integrationId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.SyncIntegration, guildId, integrationId);

            return(client.ExecuteAsync(route, null, options));
        }
예제 #11
0
        public static Task <WelcomeScreenJsonModel> FetchGuildWelcomeScreenAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.GetWelcomeScreen, guildId);

            return(client.ExecuteAsync <WelcomeScreenJsonModel>(route, null, options));
        }
예제 #12
0
        public static Task ModifyIntegrationAsync(this IRestApiClient client, Snowflake guildId, Snowflake integrationId, ModifyGuildIntegrationJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ModifyIntegration, guildId, integrationId);

            return(client.ExecuteAsync(route, content, options));
        }
예제 #13
0
        public static Task <PruneJsonModel> PruneGuildAsync(this IRestApiClient client, Snowflake guildId, int days = 7, bool computePruneCount = false, Snowflake[] roleIds = null, IRestRequestOptions options = null)
        {
            var queryParameters = new Dictionary <string, object>(roleIds != null ? 3 : 2)
            {
                ["days"] = days,
                ["compute_prune_count"] = computePruneCount
            };

            if (roleIds != null)
            {
                queryParameters["include_roles"] = roleIds;
            }

            var route = Format(Route.Guild.BeginPrune, queryParameters, guildId);

            return(client.ExecuteAsync <PruneJsonModel>(route, null, options));
        }
예제 #14
0
        public static Task <PruneJsonModel> FetchPruneGuildCountAsync(this IRestApiClient client, Snowflake guildId, int days = 7, Snowflake[] roleIds = null, IRestRequestOptions options = null)
        {
            var queryParameters = new Dictionary <string, object>(roleIds != null ? 2 : 1)
            {
                ["days"] = days
            };

            if (roleIds != null)
            {
                queryParameters["include_roles"] = roleIds;
            }

            var route = Format(Route.Guild.GetPruneCount, queryParameters, guildId);

            return(client.ExecuteAsync <PruneJsonModel>(route, null, options));
        }
예제 #15
0
        public static Task <ThreadListJsonModel> FetchActiveThreadsAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ListActiveThreads, guildId);

            return(client.ExecuteAsync <ThreadListJsonModel>(route, null, options));
        }
예제 #16
0
        public static Task <GuildWidgetJsonModel> ModifyGuildWidgetAsync(this IRestApiClient client, Snowflake guildId, ModifyGuildWidgetSettingsJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ModifyWidget, guildId);

            return(client.ExecuteAsync <GuildWidgetJsonModel>(route, content, options));
        }
예제 #17
0
        public static Task <MemberJsonModel> FetchMemberAsync(this IRestApiClient client, Snowflake guildId, Snowflake memberId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.GetMember, guildId, memberId);

            return(client.ExecuteAsync <MemberJsonModel>(route, null, options));
        }
예제 #18
0
        public static Task <InviteJsonModel> FetchGuildVanityInviteAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.GetVanityUrl, guildId);

            return(client.ExecuteAsync <InviteJsonModel>(route, null, options));
        }
예제 #19
0
        public static Task <GuildJsonModel> CreateGuildAsync(this IRestApiClient client, CreateGuildJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.CreateGuild);

            return(client.ExecuteAsync <GuildJsonModel>(route, content, options));
        }
예제 #20
0
        public static Task ModifyMemberVoiceStateAsync(this IRestApiClient client, Snowflake guildId, Snowflake memberId, ModifyMemberVoiceStateJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ModifyMemberVoiceState, guildId, memberId);

            return(client.ExecuteAsync(route, content, options));
        }
예제 #21
0
        protected override async Task <IReadOnlyList <IThreadChannel> > NextPageAsync(IReadOnlyList <IThreadChannel> previousPage, IRestRequestOptions options = null)
        {
            var startFromId = _startFromId;

            if (previousPage != null && previousPage.Count > 0)
            {
                startFromId = previousPage[^ 1].Id;
예제 #22
0
        public static Task DeleteGuildAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.DeleteGuild, guildId);

            return(client.ExecuteAsync(route, null, options));
        }
예제 #23
0
 /// <summary>
 ///     Instantiates a new <see cref="TypingRepeater"/>.
 /// </summary>
 /// <param name="client"> The client to execute the requests with. </param>
 /// <param name="channelId"> The ID of the channel to trigger typing in. </param>
 /// <param name="options"> The request options. </param>
 /// <param name="cancellationToken"> The cancellation token to observe. </param>
 public TypingRepeater(IRestClient client, Snowflake channelId, IRestRequestOptions options = null, CancellationToken cancellationToken = default)
     : base(client, options, cancellationToken)
 {
     ChannelId = channelId;
 }
예제 #24
0
        public static Task <ChannelJsonModel[]> FetchGuildChannelsAsync(this IRestApiClient client, Snowflake guildId, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.GetChannels, guildId);

            return(client.ExecuteAsync <ChannelJsonModel[]>(route, null, options));
        }
예제 #25
0
        public Task <IUserMessage> ModifyResponseAsync(Action <ModifyWebhookMessageActionProperties> action, IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.ModifyInteractionResponseAsync(Interaction.ApplicationId, Interaction.Token, action, options));
        }
예제 #26
0
        public static Task <ChannelJsonModel> CreateGuildChannelAsync(this IRestApiClient client, Snowflake guildId, CreateGuildChannelJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.CreateChannel, guildId);

            return(client.ExecuteAsync <ChannelJsonModel>(route, content, options));
        }
예제 #27
0
        public Task <IUserMessage> SendAsync(LocalInteractionFollowup followup, IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.CreateInteractionFollowupAsync(Interaction.ApplicationId, Interaction.Token, followup, options));
        }
예제 #28
0
        public static Task ReorderGuildChannelsAsync(this IRestApiClient client, Snowflake guildId, JsonObjectRestRequestContent <ReorderJsonRestRequestContent[]> content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.ReorderChannels, guildId);

            return(client.ExecuteAsync(route, content, options));
        }
예제 #29
0
        public Task <IUserMessage> ModifyAsync(Snowflake followupId, Action <ModifyWebhookMessageActionProperties> action, IRestRequestOptions options = null)
        {
            var client = Interaction.GetRestClient();

            return(client.ModifyInteractionFollowupAsync(Interaction.ApplicationId, Interaction.Token, followupId, action, options));
        }
예제 #30
0
        public static Task CreateBanAsync(this IRestApiClient client, Snowflake guildId, Snowflake userId, CreateBanJsonRestRequestContent content, IRestRequestOptions options = null)
        {
            var route = Format(Route.Guild.CreateBan, guildId, userId);

            return(client.ExecuteAsync(route, content, options));
        }