コード例 #1
0
        public static Task <VoiceRegionJsonModel[]> FetchVoiceRegionsAsync(this IRestApiClient client,
                                                                           IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Voice.GetVoiceRegions);

            return(client.ExecuteAsync <VoiceRegionJsonModel[]>(route, null, options, cancellationToken));
        }
コード例 #2
0
        public static Task <StickerPackListJsonModel> FetchStickerPacksAsync(this IRestApiClient client,
                                                                             IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Sticker.GetStickerPacks);

            return(client.ExecuteAsync <StickerPackListJsonModel>(route, null, options, cancellationToken));
        }
コード例 #3
0
        public static Task <InviteJsonModel> FetchInviteAsync(this IRestApiClient client,
                                                              string code, bool?withCounts = null, bool?withExpiration = null, Snowflake?eventId = null,
                                                              IRestRequestOptions options  = null, CancellationToken cancellationToken = default)
        {
            FormattedRoute route;

            if (withCounts != null || withExpiration != null || eventId != null)
            {
                var queryParameters = new Dictionary <string, object>();

                if (withCounts != null)
                {
                    queryParameters["with_counts"] = withCounts.Value;
                }

                if (withExpiration != null)
                {
                    queryParameters["with_expiration"] = withExpiration.Value;
                }

                if (eventId != null)
                {
                    queryParameters["guild_scheduled_event_id"] = eventId.Value;
                }

                route = Format(Route.Invite.GetInvite, queryParameters, code);
            }
            else
            {
                route = Format(Route.Invite.GetInvite, code);
            }

            return(client.ExecuteAsync <InviteJsonModel>(route, null, options, cancellationToken));
        }
コード例 #4
0
        public static Task <UserJsonModel> FetchCurrentUserAsync(this IRestApiClient client,
                                                                 IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.User.GetCurrentUser);

            return(client.ExecuteAsync <UserJsonModel>(route, null, options, cancellationToken));
        }
コード例 #5
0
        public static Task <MessageJsonModel> ExecuteWebhookAsync(this IRestApiClient client, Snowflake webhookId, string token, MultipartJsonPayloadRestRequestContent <ExecuteWebhookJsonRestRequestContent> content, bool wait = false, IRestRequestOptions options = null)
        {
            // TODO: query param utility
            var route = Format(Route.Webhook.ExecuteWebhook, new[] { KeyValuePair.Create("wait", (object)wait) }, webhookId, token);

            return(client.ExecuteAsync <MessageJsonModel>(route, content, options));
        }
コード例 #6
0
        public static Task <GatewayJsonModel> FetchGatewayAsync(this IRestApiClient client,
                                                                IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Gateway.GetGateway);

            return(client.ExecuteAsync <GatewayJsonModel>(route, null, options, cancellationToken));
        }
コード例 #7
0
        public static Task <AuditLogJsonModel> FetchAuditLogsAsync(this IRestApiClient client,
                                                                   Snowflake guildId, int limit = Discord.Limits.Rest.FetchAuditLogsPageSize, Snowflake?userId = null, AuditLogActionType?type = null, Snowflake?startFromId = null,
                                                                   IRestRequestOptions options  = null, CancellationToken cancellationToken = default)
        {
            var parameters = new Dictionary <string, object>
            {
                ["limit"] = limit
            };

            if (userId != null)
            {
                parameters["user_id"] = userId.Value;
            }

            if (type != null)
            {
                parameters["action_type"] = (int)type.Value;
            }

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

            var route = Format(Route.AuditLog.GetAuditLogs, parameters, guildId);

            return(client.ExecuteAsync <AuditLogJsonModel>(route, null, options, cancellationToken));
        }
コード例 #8
0
        public static Task DeleteGuildEmojiAsync(this IRestApiClient client,
                                                 Snowflake guildId, Snowflake emojiId,
                                                 IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Emoji.DeleteGuildEmoji, guildId, emojiId);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }
コード例 #9
0
        public static Task <EmojiJsonModel> ModifyGuildEmojiAsync(this IRestApiClient client,
                                                                  Snowflake guildId, Snowflake emojiId, ModifyGuildEmojiJsonRestRequestContent content,
                                                                  IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Emoji.ModifyGuildEmoji, guildId, emojiId);

            return(client.ExecuteAsync <EmojiJsonModel>(route, content, options, cancellationToken));
        }
コード例 #10
0
        public static Task <GuildTemplateJsonModel> FetchGuildTemplateAsync(this IRestApiClient client,
                                                                            string templateCode,
                                                                            IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Template.GetTemplate, templateCode);

            return(client.ExecuteAsync <GuildTemplateJsonModel>(route, null, options, cancellationToken));
        }
コード例 #11
0
        public static Task <ThreadMemberJsonModel[]> FetchThreadMembersAsync(this IRestApiClient client,
                                                                             Snowflake threadId,
                                                                             IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Channel.ListThreadMembers, threadId);

            return(client.ExecuteAsync <ThreadMemberJsonModel[]>(route, null, options, cancellationToken));
        }
コード例 #12
0
        public static Task <WebhookJsonModel> ModifyWebhookAsync(this IRestApiClient client, Snowflake webhookId, ModifyWebhookJsonRestRequestContent content, string token = null, IRestRequestOptions options = null)
        {
            var route = token == null
                ? Format(Route.Webhook.ModifyWebhook, webhookId)
                : Format(Route.Webhook.ModifyWebhookWithToken, webhookId, token);

            return(client.ExecuteAsync <WebhookJsonModel>(route, content, options));
        }
コード例 #13
0
        public static Task DeleteInitialInteractionResponseAsync(this IRestApiClient client,
                                                                 Snowflake applicationId, string interactionToken,
                                                                 IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Interactions.DeleteInitialResponse, applicationId, interactionToken);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }
コード例 #14
0
        public static Task <StageInstanceJsonModel> CreateStageInstanceAsync(this IRestApiClient client,
                                                                             Snowflake channelId, CreateStageInstanceJsonRestRequestContent content,
                                                                             IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Stages.CreateStage, channelId);

            return(client.ExecuteAsync <StageInstanceJsonModel>(route, content, options, cancellationToken));
        }
コード例 #15
0
        public static Task DeleteStageInstanceAsync(this IRestApiClient client,
                                                    Snowflake channelId,
                                                    IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Stages.DeleteStage, channelId);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }
コード例 #16
0
        public static Task <MessageJsonModel> ModifyFollowupInteractionResponseAsync(this IRestApiClient client,
                                                                                     Snowflake applicationId, string interactionToken, Snowflake messageId, ModifyWebhookMessageJsonRestRequestContent content,
                                                                                     IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Interactions.ModifyFollowupResponse, applicationId, interactionToken, messageId);

            return(client.ExecuteAsync <MessageJsonModel>(route, content, options, cancellationToken));
        }
コード例 #17
0
        public static Task CreateInitialInteractionResponseAsync(this IRestApiClient client,
                                                                 Snowflake interactionId, string interactionToken, MultipartJsonPayloadRestRequestContent <CreateInitialInteractionResponseJsonRestRequestContent> content,
                                                                 IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Interactions.CreateInitialResponse, interactionId, interactionToken);

            return(client.ExecuteAsync(route, content, options, cancellationToken));
        }
コード例 #18
0
        public static Task <MessageJsonModel> CreateFollowupInteractionResponseAsync(this IRestApiClient client,
                                                                                     Snowflake applicationId, string interactionToken, MultipartJsonPayloadRestRequestContent <CreateFollowupMessageJsonRestRequestContent> content,
                                                                                     IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Interactions.CreateFollowupResponse, applicationId, interactionToken);

            return(client.ExecuteAsync <MessageJsonModel>(route, content, options, cancellationToken));
        }
コード例 #19
0
        public static Task <EmojiJsonModel[]> FetchGuildEmojisAsync(this IRestApiClient client,
                                                                    Snowflake guildId,
                                                                    IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Emoji.GetGuildEmojis, guildId);

            return(client.ExecuteAsync <EmojiJsonModel[]>(route, null, options, cancellationToken));
        }
コード例 #20
0
        public static Task LeaveGuildAsync(this IRestApiClient client,
                                           Snowflake guildId,
                                           IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.User.LeaveGuild, guildId);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }
コード例 #21
0
        public static Task <ChannelJsonModel> CreateThreadAsync(this IRestApiClient client, Snowflake channelId, CreateThreadJsonRestRequestContent content, Snowflake?messageId = null, IRestRequestOptions options = null)
        {
            var route = messageId == null
                ? Format(Route.Channel.StartThread, channelId)
                : Format(Route.Channel.StartThreadWithMessage, channelId, messageId);

            return(client.ExecuteAsync <ChannelJsonModel>(route, content, options));
        }
コード例 #22
0
        public static Task <MessageJsonModel> FetchMessageAsync(this IRestApiClient client,
                                                                Snowflake channelId, Snowflake messageId,
                                                                IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Channel.GetMessage, channelId, messageId);

            return(client.ExecuteAsync <MessageJsonModel>(route, null, options, cancellationToken));
        }
コード例 #23
0
        public static Task <GuildScheduledEventJsonModel> ModifyGuildScheduledEventAsync(this IRestApiClient client,
                                                                                         Snowflake guildId, Snowflake eventId, ModifyGuildScheduledEventJsonRestRequestContent content,
                                                                                         IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.GuildEvents.ModifyEvent, guildId, eventId);

            return(client.ExecuteAsync <GuildScheduledEventJsonModel>(route, content, options, cancellationToken));
        }
コード例 #24
0
        public static Task DeleteGuildScheduledEventAsync(this IRestApiClient client,
                                                          Snowflake guildId, Snowflake eventId,
                                                          IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.GuildEvents.DeleteEvent, guildId, eventId);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }
コード例 #25
0
        public static Task <ChannelJsonModel> CreateDirectChannelAsync(this IRestApiClient client,
                                                                       CreateDirectChannelJsonRestRequestContent content,
                                                                       IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.User.CreateDirectChannel);

            return(client.ExecuteAsync <ChannelJsonModel>(route, content, options, cancellationToken));
        }
コード例 #26
0
        public static Task <ChannelJsonModel> DeleteChannelAsync(this IRestApiClient client,
                                                                 Snowflake channelId,
                                                                 IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Channel.DeleteChannel, channelId);

            return(client.ExecuteAsync <ChannelJsonModel>(route, null, options, cancellationToken));
        }
コード例 #27
0
        public static Task DeleteWebhookAsync(this IRestApiClient client, Snowflake webhookId, string token = null, IRestRequestOptions options = null)
        {
            var route = token == null
                ? Format(Route.Webhook.DeleteWebhook, webhookId)
                : Format(Route.Webhook.DeleteWebhookWithToken, webhookId, token);

            return(client.ExecuteAsync(route, null, options));
        }
コード例 #28
0
        public static Task <GuildTemplateJsonModel> ModifyGuildTemplateAsync(this IRestApiClient client,
                                                                             Snowflake guildId, string templateCode, ModifyGuildTemplateJsonRestRequestContent content,
                                                                             IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Template.ModifyTemplate, guildId, templateCode);

            return(client.ExecuteAsync <GuildTemplateJsonModel>(route, content, options, cancellationToken));
        }
コード例 #29
0
        public static Task <GuildJsonModel> CreateGuildFromTemplateAsync(this IRestApiClient client,
                                                                         string templateCode, CreateGuildFromTemplateJsonRestRequestContent content,
                                                                         IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Template.CreateGuild, templateCode);

            return(client.ExecuteAsync <GuildJsonModel>(route, content, options, cancellationToken));
        }
コード例 #30
0
        public static Task RemoveThreadMemberAsync(this IRestApiClient client,
                                                   Snowflake threadId, Snowflake memberId,
                                                   IRestRequestOptions options = null, CancellationToken cancellationToken = default)
        {
            var route = Format(Route.Channel.RemoveThreadMember, threadId, memberId);

            return(client.ExecuteAsync(route, null, options, cancellationToken));
        }