From 0ac93117ee45b50b4c39e5711613dbc4615b7e88 Mon Sep 17 00:00:00 2001 From: andreas-henning <976431@outlook.com> Date: Sun, 25 Sep 2022 02:37:53 +0200 Subject: [PATCH] Code style adheres to .editorconfig --- Anarchy/Anarchy.csproj | 3 +- Anarchy/Commands/Command/CommandHandler.cs | 5 +-- .../Commands/SlashCommands/SlashCommand.cs | 2 +- .../SlashCommands/SlashCommandHandler.cs | 6 +-- Anarchy/Local/Controllable/Controllable.cs | 1 - Anarchy/Local/Controllable/Extensions.cs | 1 - Anarchy/Local/Controllable/JsonExtensions.cs | 2 +- Anarchy/Local/DiscordImage.cs | 2 +- Anarchy/Local/DiscordParameter.cs | 2 - Anarchy/REST/Billing/BillingAddress.cs | 6 --- Anarchy/REST/Billing/CardPaymentMethod.cs | 4 -- Anarchy/REST/Billing/DiscordPayment.cs | 7 ---- Anarchy/REST/Billing/Extensions.cs | 1 - Anarchy/REST/Billing/PaymentMethod.cs | 7 ---- .../Channel/Channel/CreationProperties.cs | 2 - .../REST/Channel/Channel/DiscordChannel.cs | 6 --- Anarchy/REST/Channel/Channel/Extensions.cs | 3 -- .../Channel/Channel/MinimalTextChannel.cs | 8 ---- Anarchy/REST/Channel/Guild/Extensions.cs | 4 -- .../REST/Channel/Guild/Guild/GuildChannel.cs | 11 +---- .../Guild/Guild/GuildChannelProperties.cs | 3 -- .../Guild/Stage/DiscordStageInstance.cs | 1 - .../REST/Channel/Guild/Stage/StageChannel.cs | 1 - .../REST/Channel/Guild/Text/TextChannel.cs | 23 +---------- .../Guild/Text/TextChannelProperties.cs | 5 --- .../REST/Channel/Guild/Voice/VoiceChannel.cs | 7 +--- .../Guild/Voice/VoiceChannelProperties.cs | 3 -- Anarchy/REST/Channel/Private/DM/Extensions.cs | 2 - .../REST/Channel/Private/DM/PrivateChannel.cs | 17 +------- .../Channel/Private/Group/DiscordGroup.cs | 9 +--- .../REST/Channel/Private/Group/Extensions.cs | 6 +-- .../Channel/Private/Group/GroupProperties.cs | 2 - Anarchy/REST/DiscordClient.cs | 2 - Anarchy/REST/Discovery/DiscoveryGuild.cs | 11 +---- Anarchy/REST/Discovery/Extensions.cs | 4 +- Anarchy/REST/Discovery/GuildQueryResult.cs | 1 - Anarchy/REST/Embed/Author.cs | 4 -- Anarchy/REST/Embed/DiscordEmbed.cs | 16 +------- Anarchy/REST/Embed/EmbedException.cs | 1 - Anarchy/REST/Embed/EmbedMaker.cs | 15 ------- Anarchy/REST/Embed/Field.cs | 5 --- Anarchy/REST/Embed/Footer.cs | 3 -- Anarchy/REST/Embed/Image.cs | 3 -- Anarchy/REST/Embed/Video.cs | 3 -- Anarchy/REST/Emoji/Extentions.cs | 4 -- Anarchy/REST/Emoji/Models/DiscordEmoji.cs | 11 ++--- Anarchy/REST/Emoji/Models/EmojiContainer.cs | 2 - Anarchy/REST/Emoji/Models/EmojiProperties.cs | 1 - Anarchy/REST/Emoji/Models/PartialEmoji.cs | 6 --- Anarchy/REST/Gifts/DiscordGift.cs | 5 --- Anarchy/REST/Gifts/Extensions.cs | 7 ---- Anarchy/REST/Gifts/PurchaseOptions.cs | 3 -- Anarchy/REST/Gifts/RedeemableDiscordGift.cs | 6 --- Anarchy/REST/Guild/AuditLog/Extensions.cs | 2 +- Anarchy/REST/Guild/AuditLog/Models/Change.cs | 3 -- Anarchy/REST/Guild/AuditLog/Models/Entry.cs | 7 ---- Anarchy/REST/Guild/AuditLog/Models/Filters.cs | 3 -- .../Guild/Community/CommunityExtensions.cs | 4 -- .../Screening/VerificationFormProperties.cs | 2 - .../Screening/VerificationFormResponse.cs | 3 -- .../REST/Guild/Community/WelcomeChannel.cs | 2 - .../Community/WelcomeChannelProperties.cs | 3 -- Anarchy/REST/Guild/Community/WelcomeScreen.cs | 1 - .../Community/WelcomeScreenProperties.cs | 2 - Anarchy/REST/Guild/Extensions.cs | 14 ------- Anarchy/REST/Guild/Guild/BaseGuild.cs | 4 -- Anarchy/REST/Guild/Guild/DiscordGuild.cs | 25 ----------- Anarchy/REST/Guild/Guild/MinimalGuild.cs | 29 ------------- Anarchy/REST/Guild/Guild/PartialGuild.cs | 3 -- Anarchy/REST/Guild/Member/Extensions.cs | 6 --- .../REST/Guild/Member/Models/DiscordBan.cs | 5 --- .../REST/Guild/Member/Models/GuildMember.cs | 19 +-------- .../Member/Models/GuildMemberProperties.cs | 9 ---- .../Member/Models/MemberPruneProperties.cs | 3 -- .../Guild/Member/Models/PartialGuildMember.cs | 4 -- .../Permissions/DiscordPermissionOverwrite.cs | 4 -- .../Guild/Properties/CreationProperties.cs | 2 - .../REST/Guild/Properties/GuildProperties.cs | 18 -------- Anarchy/REST/Guild/Role/Extensions.cs | 6 --- Anarchy/REST/Guild/Role/Models/DiscordRole.cs | 16 +------- Anarchy/REST/Guild/Role/Models/MinimalRole.cs | 4 -- .../Guild/Role/Models/RolePositionUpdate.cs | 1 - .../REST/Guild/Role/Models/RoleProperties.cs | 14 +------ .../Settings/ChannelSettingsProperties.cs | 5 --- .../Guild/Settings/ClientGuildSettings.cs | 6 --- .../Guild/Settings/DiscordChannelSettings.cs | 2 - .../REST/Guild/Settings/GuildMuteConfig.cs | 1 - .../Guild/Settings/GuildSettingsProperties.cs | 4 -- .../Guild/Templates/DiscordGuildTemplate.cs | 10 ----- .../Guild/Templates/DiscordTemplateGuild.cs | 5 --- .../Templates/GuildTemplateExtensions.cs | 4 -- Anarchy/REST/Guild/Threads/DiscordThread.cs | 7 ---- .../REST/Guild/Threads/ThreadProperties.cs | 4 +- .../Webhook/Default/DiscordDefaultWebhook.cs | 6 +-- .../Webhook/Default/DiscordWebhookProfile.cs | 1 - .../Default/WebhookMessageProperties.cs | 5 --- Anarchy/REST/Guild/Webhook/DiscordWebhook.cs | 11 ----- .../Guild/Webhook/DiscordWebhookProperties.cs | 6 --- Anarchy/REST/Guild/Webhook/Extensions.cs | 7 ---- .../Following/DiscordCrosspostWebhook.cs | 4 -- Anarchy/REST/HTTP/DiscordHttpClient.cs | 7 +--- Anarchy/REST/HTTP/DiscordHttpError.cs | 3 -- Anarchy/REST/HTTP/DiscordHttpResponse.cs | 6 +-- Anarchy/REST/HTTP/DiscordHttpUtil.cs | 2 +- .../HTTP/Exceptions/DiscordHttpException.cs | 4 +- .../HTTP/Exceptions/RateLimitException.cs | 1 - .../InteractionResponseProperties.cs | 4 -- .../SlashCommands/ApplicationCommand.cs | 2 - .../ApplicationCommandProperties.cs | 3 -- .../SlashCommands/SlashCommandExtensions.cs | 5 --- Anarchy/REST/Invite/Extensions.cs | 3 -- Anarchy/REST/Invite/Models/DiscordInvite.cs | 8 ---- Anarchy/REST/Invite/Models/GuildInvite.cs | 6 +-- Anarchy/REST/Invite/Models/InviteGuild.cs | 5 --- .../REST/Invite/Models/InviteProperties.cs | 2 - Anarchy/REST/Message/Extensions.cs | 20 +-------- .../REST/Message/Message/DeletedMessage.cs | 3 -- .../REST/Message/Message/DiscordAttachment.cs | 7 ---- .../REST/Message/Message/DiscordMessage.cs | 34 --------------- Anarchy/REST/Message/Message/MessageAuthor.cs | 1 - .../Properties/MessageEditProperties.cs | 2 - .../Message/Properties/MessageFilters.cs | 6 --- .../Message/Properties/MessageProperties.cs | 6 --- .../Properties/PartialDiscordAttachment.cs | 4 -- Anarchy/REST/Message/Message/UserTyping.cs | 6 +-- .../REST/Message/Reaction/MessageReaction.cs | 4 -- Anarchy/REST/Message/Reaction/Update.cs | 6 --- .../REST/OAuth2/Client/DiscordOAuth2Client.cs | 5 +-- .../Client/OAuth2GuildJoinProperties.cs | 3 -- Anarchy/REST/OAuth2/Extensions.cs | 8 ---- Anarchy/REST/OAuth2/Models/ApplicationBot.cs | 7 ---- Anarchy/REST/OAuth2/Models/AuthorizedApp.cs | 4 -- .../Models/DiscordApplicationProperties.cs | 10 ----- .../OAuth2/Models/DiscordBotAuthProperties.cs | 3 -- .../REST/OAuth2/Models/OAuth2Application.cs | 17 -------- Anarchy/REST/Relationships/Extensions.cs | 6 --- .../Models/DiscordRelationship.cs | 4 -- .../Subscriptions/Nitro/DiscordBoostSlot.cs | 4 -- .../Nitro/DiscordGuildSubscription.cs | 4 -- .../REST/Subscriptions/Nitro/Extensions.cs | 5 +-- .../AdditionalSubscriptionPlan.cs | 1 - .../DiscordActiveSubscription.cs | 8 ---- .../Subscriptions/DiscordSubscription.cs | 2 - .../Subscriptions/Subscriptions/Extensions.cs | 3 +- .../Subscriptions/SubscriptionPlan.cs | 6 --- Anarchy/REST/SuperProperties.cs | 5 +-- .../Connections/ClientConnectedAccount.cs | 3 -- .../REST/User/Connections/ConnectedAccount.cs | 6 +-- Anarchy/REST/User/Connections/Extensions.cs | 2 - Anarchy/REST/User/Extensions.cs | 2 - Anarchy/REST/User/Profile/DiscordProfile.cs | 6 --- Anarchy/REST/User/Profile/MutualGuild.cs | 2 - .../REST/User/Profile/UserProfileUpdate.cs | 12 ------ Anarchy/REST/User/Settings/CustomStatus.cs | 3 -- .../REST/User/Settings/DiscordGuildFolder.cs | 6 --- .../User/Settings/DiscordGuildFolderUpdate.cs | 8 +--- .../REST/User/Settings/DiscordUserSettings.cs | 12 +----- .../User/Settings/UserSettingsProperties.cs | 26 +----------- Anarchy/REST/User/User/DiscordClientUser.cs | 18 +------- Anarchy/REST/User/User/DiscordLanguage.cs | 2 +- Anarchy/REST/User/User/DiscordUser.cs | 22 +--------- .../User/User/UserReportIdentification.cs | 2 - Anarchy/REST/Voice/Extensions.cs | 4 -- Anarchy/REST/Voice/VoiceRegion.cs | 6 --- Anarchy/WebSockets/DiscordWebSocket.cs | 4 +- Anarchy/WebSockets/DiscordWebSocketMessage.cs | 1 - Anarchy/WebSockets/DiscordWebSocketRequest.cs | 1 - .../Gateway/Channel/ChannelEventArgs.cs | 1 - .../Channel/GatewayChannelExtensions.cs | 13 +++--- .../Private/ChannelRecipientEventArgs.cs | 1 - .../Gateway/Channel/Private/DiscordCall.cs | 3 -- .../GatewayPrivateChannelExtensions.cs | 2 +- .../WebSockets/Gateway/DiscordSocketClient.cs | 41 +++++++------------ .../Gateway/Emojis/GatewayEmojiExtensions.cs | 6 +-- .../Gateway/General/LogoutEventArgs.cs | 2 +- .../Gateway/Gifts/DiscordEntitlement.cs | 8 ---- .../Gateway/Gifts/GiftCodeCreatedEventArgs.cs | 1 - .../Gateway/Gifts/GiftCodeUpdatedEventArgs.cs | 3 -- .../WebSockets/Gateway/Guild/Extensions.cs | 10 +---- .../Guild/Member/BanUpdateEventArgs.cs | 2 - .../Guild/Member/Query/GuildMemberList.cs | 4 -- .../Guild/Member/Query/GuildMemberQuery.cs | 2 - .../Gateway/Guild/Models/GuildEventArgs.cs | 1 - .../Gateway/Guild/Models/SocketGuild.cs | 14 ++----- .../Gateway/Guild/Models/UnavailableGuild.cs | 2 - .../Gateway/Interaction/DiscordInteraction.cs | 1 - .../Interaction/Forms/ComponentFormButton.cs | 1 - .../Interaction/Forms/DiscordComponentForm.cs | 4 +- .../Gateway/Invite/InviteCreatedEventArgs.cs | 7 ---- .../Gateway/Invite/InviteDeletedEventArgs.cs | 2 - .../Gateway/Media/DiscordMediaServer.cs | 4 -- .../WebSockets/Gateway/Media/Extensions.cs | 4 -- .../Gateway/Media/Go Live/GoLiveUpdate.cs | 3 -- .../Gateway/Media/Go Live/StartStream.cs | 3 -- .../Gateway/Media/Voice/DiscordVoiceState.cs | 11 ----- .../Media/Voice/VoiceDisconnectEventArgs.cs | 2 +- .../Media/Voice/VoiceStateEventArgs.cs | 1 - .../Media/Voice/VoiceStateProperties.cs | 8 +--- .../Gateway/Message/MessageEventArgs.cs | 1 - .../Gateway/Message/ReactionEventArgs.cs | 1 - .../Gateway/Message/UserTypingEventArgs.cs | 2 - .../Activity/Properties/ActivityProperties.cs | 2 - .../Properties/GameActivityProperties.cs | 4 -- .../Properties/StreamActivityProperties.cs | 1 - .../Presence/Activity/TimestampProperties.cs | 1 - .../Activity/User/CustomStatusActivity.cs | 2 - .../Presence/Activity/User/DiscordActivity.cs | 3 -- .../Activity/User/DiscordGameActivity.cs | 1 - .../Activity/User/DiscordListeningActivity.cs | 2 - .../WebSockets/Gateway/Presence/Extensions.cs | 3 -- .../Presence/ActiveSessionPlatforms.cs | 2 - .../Presence/Presence/DiscordPresence.cs | 6 --- .../Presence/Presence/PresenceProperties.cs | 4 -- .../Presence/Presence/UpdatedEventArgs.cs | 1 - .../WebSockets/Gateway/Role/DeletedRole.cs | 1 - .../Gateway/Role/GatewayRoleExtensions.cs | 3 +- .../WebSockets/Gateway/Role/RoleEventArgs.cs | 1 - Anarchy/WebSockets/Gateway/Role/RoleUpdate.cs | 2 - .../Gateway/Session/Auth/Identification.cs | 8 ---- .../Gateway/Session/Auth/LoginEventArgs.cs | 14 ------- .../WebSockets/Gateway/Session/Auth/Resume.cs | 2 - .../Gateway/Session/DiscordSession.cs | 3 -- .../Session/DiscordSessionClientInfo.cs | 2 - .../WebSockets/Gateway/Session/Extensions.cs | 1 - .../Subscriptions/NitroBoostEventArgs.cs | 1 - .../Gateway/User/RelationshipEventArgs.cs | 2 - .../User/RemovedRelationshipEventArgs.cs | 1 - .../WebSockets/Gateway/User/UserEventArgs.cs | 1 - Anarchy/WebSockets/Gateway/User/UserStatus.cs | 4 +- Anarchy/WebSockets/Media/Codecs/MediaCodec.cs | 5 +-- .../Media/Codecs/Opus/OpusDecoder.cs | 2 +- .../Media/Codecs/Opus/OpusEncoder.cs | 8 ++-- .../Livestreaming/DiscordLivestreamSession.cs | 1 - .../Media/Media/Auth/DiscordMediaIdentify.cs | 4 -- .../Media/Media/Auth/DiscordMediaReady.cs | 4 -- .../Media/Auth/DiscordSessionDescription.cs | 2 - .../Media/Media/DiscordMediaConnection.cs | 17 +++----- .../Media/Media/Payloads/DiscordSSRC.cs | 2 - .../Media/Payloads/MediaCodecSelection.cs | 2 - .../Media/Media/Payloads/MediaProtocolData.cs | 2 - .../Media/Payloads/MediaProtocolSelection.cs | 5 --- .../WebSockets/Media/RTP/RTPPacketHeader.cs | 27 ++++++------ .../Media/Voice/DiscordVoiceInput.cs | 6 +-- .../Voice/Speaking/DiscordSpeakingRequest.cs | 2 - .../Voice/Speaking/DiscordSpeakingState.cs | 2 - .../Voice/Speaking/IncomingVoiceStream.cs | 3 -- 246 files changed, 117 insertions(+), 1220 deletions(-) diff --git a/Anarchy/Anarchy.csproj b/Anarchy/Anarchy.csproj index f0f7d6be..e5adf9fe 100644 --- a/Anarchy/Anarchy.csproj +++ b/Anarchy/Anarchy.csproj @@ -6,7 +6,8 @@ true full prompt - 4 + true + 4 AnyCPU IDE1006, CS0649, CS0414, IDE0051 True diff --git a/Anarchy/Commands/Command/CommandHandler.cs b/Anarchy/Commands/Command/CommandHandler.cs index ca8418a5..da0ea068 100644 --- a/Anarchy/Commands/Command/CommandHandler.cs +++ b/Anarchy/Commands/Command/CommandHandler.cs @@ -30,7 +30,6 @@ internal CommandHandler(string prefix, DiscordSocketClient client) } } - private void Client_OnMessageReceived(DiscordSocketClient client, MessageEventArgs args) { if (args.Message.Content.StartsWith(Prefix)) @@ -41,7 +40,7 @@ private void Client_OnMessageReceived(DiscordSocketClient client, MessageEventAr { parts.RemoveAt(0); - CommandBase inst = (CommandBase)Activator.CreateInstance(command.Type); + CommandBase inst = (CommandBase) Activator.CreateInstance(command.Type); inst.Prepare(_client, args.Message); for (int i = 0; i < command.Parameters.Count; i++) @@ -171,7 +170,7 @@ internal static bool TryGetAttribute(IEnumerable attributes, out { if (attribute.GetType() == typeof(TAttr)) { - attr = (TAttr)attribute; + attr = (TAttr) attribute; return true; } } diff --git a/Anarchy/Commands/SlashCommands/SlashCommand.cs b/Anarchy/Commands/SlashCommands/SlashCommand.cs index a68856ec..b5047576 100644 --- a/Anarchy/Commands/SlashCommands/SlashCommand.cs +++ b/Anarchy/Commands/SlashCommands/SlashCommand.cs @@ -14,7 +14,7 @@ public abstract class SlashCommand internal void Prepare(DiscordInteraction interaction) { - Client = (DiscordSocketClient)interaction.Client; + Client = (DiscordSocketClient) interaction.Client; Caller = interaction.User; CallerMember = interaction.Member; diff --git a/Anarchy/Commands/SlashCommands/SlashCommandHandler.cs b/Anarchy/Commands/SlashCommands/SlashCommandHandler.cs index 7bccc4f7..6f5cce80 100644 --- a/Anarchy/Commands/SlashCommands/SlashCommandHandler.cs +++ b/Anarchy/Commands/SlashCommands/SlashCommandHandler.cs @@ -50,7 +50,7 @@ public SlashCommandHandler(DiscordSocketClient client, ulong appId, ulong? guild { if (choices == null) choices = new List(); - var choiceAttr = (SlashParameterChoiceAttribute)ok; + var choiceAttr = (SlashParameterChoiceAttribute) ok; if (choiceAttr.Value.GetType() != typeof(string) && !IsInteger(choiceAttr.Value.GetType())) throw new InvalidOperationException("All choice values must either be strings or integers"); @@ -177,7 +177,7 @@ private void Handle(string cmdName, DiscordInteraction interaction, List(IEnumerable attributes, out T { if (attribute.GetType() == typeof(TAttr)) { - attr = (TAttr)attribute; + attr = (TAttr) attribute; return true; } } diff --git a/Anarchy/Local/Controllable/Controllable.cs b/Anarchy/Local/Controllable/Controllable.cs index 76d5e068..b9118393 100644 --- a/Anarchy/Local/Controllable/Controllable.cs +++ b/Anarchy/Local/Controllable/Controllable.cs @@ -20,7 +20,6 @@ public DiscordClient Client } } - public void Dispose() { _client = null; diff --git a/Anarchy/Local/Controllable/Extensions.cs b/Anarchy/Local/Controllable/Extensions.cs index bcc0af05..ecfddb2d 100644 --- a/Anarchy/Local/Controllable/Extensions.cs +++ b/Anarchy/Local/Controllable/Extensions.cs @@ -11,7 +11,6 @@ public static T SetClient(this T @class, DiscordClient client) where T : Cont return @class; } - internal static IReadOnlyList SetClientsInList(this IReadOnlyList classes, DiscordClient client) where T : Controllable { if (classes != null) diff --git a/Anarchy/Local/Controllable/JsonExtensions.cs b/Anarchy/Local/Controllable/JsonExtensions.cs index c439360b..f7f7f5d3 100644 --- a/Anarchy/Local/Controllable/JsonExtensions.cs +++ b/Anarchy/Local/Controllable/JsonExtensions.cs @@ -24,7 +24,7 @@ public static T ParseDeterministic(this JObject obj) if (TryFindTypes(typeof(T), out Dictionary types)) { int type = obj.Value("type"); - return (T)obj.ToObject(types.TryGetValue(type, out var t) ? t : typeof(T)); + return (T) obj.ToObject(types.TryGetValue(type, out var t) ? t : typeof(T)); } else throw new InvalidCastException("Unable to find any implementations for T"); diff --git a/Anarchy/Local/DiscordImage.cs b/Anarchy/Local/DiscordImage.cs index 4ba5cba7..a560d77f 100644 --- a/Anarchy/Local/DiscordImage.cs +++ b/Anarchy/Local/DiscordImage.cs @@ -5,7 +5,7 @@ namespace Discord { - class ImageJsonConverter : JsonConverter + internal class ImageJsonConverter : JsonConverter { public override bool CanRead => false; diff --git a/Anarchy/Local/DiscordParameter.cs b/Anarchy/Local/DiscordParameter.cs index f30f47d9..2d50996c 100644 --- a/Anarchy/Local/DiscordParameter.cs +++ b/Anarchy/Local/DiscordParameter.cs @@ -17,13 +17,11 @@ public T Value } } - public static implicit operator T(DiscordParameter instance) { return instance.Value; } - public override string ToString() { return Value.ToString(); diff --git a/Anarchy/REST/Billing/BillingAddress.cs b/Anarchy/REST/Billing/BillingAddress.cs index beaaef14..d3624700 100644 --- a/Anarchy/REST/Billing/BillingAddress.cs +++ b/Anarchy/REST/Billing/BillingAddress.cs @@ -7,27 +7,21 @@ public class BillingAddress [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("line_1")] public string Address1 { get; private set; } - [JsonProperty("line_2")] public string Address2 { get; private set; } - [JsonProperty("city")] public string City { get; private set; } - [JsonProperty("state")] public string State { get; private set; } - [JsonProperty("country")] public string Country { get; private set; } - [JsonProperty("postal_code")] public dynamic PostalCode { get; private set; } } diff --git a/Anarchy/REST/Billing/CardPaymentMethod.cs b/Anarchy/REST/Billing/CardPaymentMethod.cs index 945338e9..471a7806 100644 --- a/Anarchy/REST/Billing/CardPaymentMethod.cs +++ b/Anarchy/REST/Billing/CardPaymentMethod.cs @@ -7,19 +7,15 @@ public class CardPaymentMethod : PaymentMethod [JsonProperty("brand")] public string Brand { get; private set; } - [JsonProperty("country")] public string Country { get; private set; } - [JsonProperty("last_4")] public int Last4 { get; private set; } - [JsonProperty("expires_month")] public int ExpirationMonth { get; private set; } - [JsonProperty("expires_year")] public int ExpirationYear { get; private set; } } diff --git a/Anarchy/REST/Billing/DiscordPayment.cs b/Anarchy/REST/Billing/DiscordPayment.cs index 915870ad..347a184a 100644 --- a/Anarchy/REST/Billing/DiscordPayment.cs +++ b/Anarchy/REST/Billing/DiscordPayment.cs @@ -13,31 +13,24 @@ public DiscordPayment() [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("created_at")] public DateTime Timestamp { get; private set; } - [JsonProperty("currency")] public string Currency { get; private set; } - [JsonProperty("amount")] public string Amount { get; private set; } - [JsonProperty("status")] public DiscordPaymentStatus Status { get; private set; } - [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("flags")] public DiscordPaymentFlags Flags { get; private set; } - [JsonProperty("payment_source")] [JsonConverter(typeof(DeepJsonConverter))] public PaymentMethod PaymentMethod { get; private set; } diff --git a/Anarchy/REST/Billing/Extensions.cs b/Anarchy/REST/Billing/Extensions.cs index 21e9d121..601e88fc 100644 --- a/Anarchy/REST/Billing/Extensions.cs +++ b/Anarchy/REST/Billing/Extensions.cs @@ -16,7 +16,6 @@ public static IReadOnlyList GetPayments(this DiscordClient clien return client.GetPaymentsAsync(limit).GetAwaiter().GetResult(); } - public static async Task> GetPaymentMethodsAsync(this DiscordClient client) { return (await client.HttpClient.GetAsync("/users/@me/billing/payment-sources")) diff --git a/Anarchy/REST/Billing/PaymentMethod.cs b/Anarchy/REST/Billing/PaymentMethod.cs index fde0b9d2..be9d3506 100644 --- a/Anarchy/REST/Billing/PaymentMethod.cs +++ b/Anarchy/REST/Billing/PaymentMethod.cs @@ -8,27 +8,21 @@ public class PaymentMethod : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("type")] public PaymentMethodType Type { get; private set; } - [JsonProperty("invalid")] public bool Invalid { get; private set; } - [JsonProperty("billing_address")] public BillingAddress BillingAddress { get; private set; } - [JsonProperty("country")] public string County { get; private set; } - [JsonProperty("default")] public bool Default { get; private set; } - public async Task PurchaseGiftAsync(ulong skuId, ulong subPlanId, int expectedAmount) { return await Client.PurchaseGiftAsync(Id, skuId, subPlanId, expectedAmount); @@ -39,7 +33,6 @@ public string PurchaseGift(ulong skuId, ulong subPlanId, int expectedAmount) return PurchaseGiftAsync(skuId, subPlanId, expectedAmount).GetAwaiter().GetResult(); } - public async Task PurchaseNitroGiftAsync(DiscordNitroSubType nitroType) { return await Client.PurchaseNitroGiftAsync(Id, nitroType); diff --git a/Anarchy/REST/Channel/Channel/CreationProperties.cs b/Anarchy/REST/Channel/Channel/CreationProperties.cs index d3e19820..85a88bbf 100644 --- a/Anarchy/REST/Channel/Channel/CreationProperties.cs +++ b/Anarchy/REST/Channel/Channel/CreationProperties.cs @@ -10,11 +10,9 @@ public class ChannelCreationProperties [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("type")] public ChannelType Type { get; set; } - public override string ToString() { return Type.ToString(); diff --git a/Anarchy/REST/Channel/Channel/DiscordChannel.cs b/Anarchy/REST/Channel/Channel/DiscordChannel.cs index 65686856..7e038fd1 100644 --- a/Anarchy/REST/Channel/Channel/DiscordChannel.cs +++ b/Anarchy/REST/Channel/Channel/DiscordChannel.cs @@ -8,11 +8,9 @@ public class DiscordChannel : MinimalChannel [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("type")] public ChannelType Type { get; protected set; } - public bool InGuild { get { return Type != ChannelType.DM && Type != ChannelType.Group; } @@ -28,7 +26,6 @@ public bool IsVoice get { return Type == ChannelType.Voice || Type == ChannelType.DM || Type == ChannelType.Group || Type == ChannelType.Stage; } } - protected void Update(DiscordChannel channel) { Name = channel.Name; @@ -47,17 +44,14 @@ public void Update() UpdateAsync().GetAwaiter().GetResult(); } - // retarded solution but it's the best i could come up with internal virtual void SetLastMessageId(ulong id) { } - public override string ToString() { return Name; } - public static implicit operator ulong(DiscordChannel instance) { return instance.Id; diff --git a/Anarchy/REST/Channel/Channel/Extensions.cs b/Anarchy/REST/Channel/Channel/Extensions.cs index 69022849..3e080151 100644 --- a/Anarchy/REST/Channel/Channel/Extensions.cs +++ b/Anarchy/REST/Channel/Channel/Extensions.cs @@ -19,7 +19,6 @@ public static DiscordChannel GetChannel(this DiscordClient client, ulong channel return client.GetChannelAsync(channelId).GetAwaiter().GetResult(); } - public static async Task ModifyGroupAsync(this DiscordClient client, ulong groupId, GroupProperties properties) { return (await client.HttpClient.PatchAsync($"/channels/{groupId}", properties)) @@ -31,7 +30,6 @@ public static DiscordGroup ModifyGroup(this DiscordClient client, ulong groupId, return client.ModifyGroupAsync(groupId, properties).GetAwaiter().GetResult(); } - public static async Task ModifyGuildChannelAsync(this DiscordClient client, ulong channelId, GuildChannelProperties properties) { return (await client.HttpClient.PatchAsync($"/channels/{channelId}", properties)) @@ -43,7 +41,6 @@ public static GuildChannel ModifyGuildChannel(this DiscordClient client, ulong c return client.ModifyGuildChannelAsync(channelId, properties).GetAwaiter().GetResult(); } - public static async Task DeleteChannelAsync(this DiscordClient client, ulong channelId) { return (await client.HttpClient.DeleteAsync($"/channels/{channelId}")) diff --git a/Anarchy/REST/Channel/Channel/MinimalTextChannel.cs b/Anarchy/REST/Channel/Channel/MinimalTextChannel.cs index 8abcc04c..d9c5f0ac 100644 --- a/Anarchy/REST/Channel/Channel/MinimalTextChannel.cs +++ b/Anarchy/REST/Channel/Channel/MinimalTextChannel.cs @@ -23,7 +23,6 @@ public void TriggerTyping() TriggerTypingAsync().GetAwaiter().GetResult(); } - public Task SendMessageAsync(MessageProperties properties) { return Client.SendMessageAsync(Id, properties); @@ -60,7 +59,6 @@ public DiscordMessage SendMessage(EmbedMaker embed) return SendMessageAsync(embed).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string fileName, byte[] fileData, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, fileName, fileData, message, tts); @@ -71,7 +69,6 @@ public DiscordMessage SendFile(string fileName, byte[] fileData, string message return SendFileAsync(fileName, fileData, message, tts).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string filePath, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, filePath, message, tts); @@ -82,7 +79,6 @@ public DiscordMessage SendFile(string filePath, string message = null, bool tts return SendFileAsync(filePath, message, tts).GetAwaiter().GetResult(); } - public async Task DeleteMessagesAsync(List messages) { await Client.DeleteMessagesAsync(Id, messages); @@ -98,7 +94,6 @@ public void DeleteMessages(List messages) DeleteMessagesAsync(messages).GetAwaiter().GetResult(); } - public async Task> GetMessagesAsync(MessageFilters filters = null) { return await Client.GetChannelMessagesAsync(Id, filters); @@ -113,7 +108,6 @@ public IReadOnlyList GetMessages(MessageFilters filters = null) return GetMessagesAsync(filters).GetAwaiter().GetResult(); } - public async Task> GetPinnedMessagesAsync() { return await Client.GetPinnedMessagesAsync(Id); @@ -127,7 +121,6 @@ public IReadOnlyList GetPinnedMessages() return GetPinnedMessagesAsync().GetAwaiter().GetResult(); } - public async Task PinMessageAsync(ulong messageId) { await Client.PinMessageAsync(Id, messageId); @@ -142,7 +135,6 @@ public void PinMessage(ulong messageId) PinMessageAsync(messageId).GetAwaiter().GetResult(); } - public async Task UnpinMessageAsync(ulong messageId) { await Client.UnpinChannelMessageAsync(Id, messageId); diff --git a/Anarchy/REST/Channel/Guild/Extensions.cs b/Anarchy/REST/Channel/Guild/Extensions.cs index 4e71367a..1414c4b0 100644 --- a/Anarchy/REST/Channel/Guild/Extensions.cs +++ b/Anarchy/REST/Channel/Guild/Extensions.cs @@ -26,7 +26,6 @@ public static IReadOnlyList GetGuildChannels(this DiscordClient cl return client.GetGuildChannelsAsync(guildId).GetAwaiter().GetResult(); } - public static async Task CreateGuildChannelAsync(this DiscordClient client, ulong guildId, string name, ChannelType type, ulong? parentId = null) { var channel = (await client.HttpClient.PostAsync($"/guilds/{guildId}/channels", new GuildChannelCreationProperties() { Name = name, Type = type, ParentId = parentId })) @@ -47,7 +46,6 @@ public static GuildChannel CreateGuildChannel(this DiscordClient client, ulong g return client.CreateGuildChannelAsync(guildId, name, type, parentId).GetAwaiter().GetResult(); } - public static async Task AddPermissionOverwriteAsync(this DiscordClient client, ulong channelId, ulong affectedId, PermissionOverwriteType type, DiscordPermission allow, DiscordPermission deny) { var overwrite = new DiscordPermissionOverwrite() { AffectedId = affectedId, Type = type, Allow = allow, Deny = deny }; @@ -67,7 +65,6 @@ public static DiscordPermissionOverwrite AddPermissionOverwrite(this DiscordClie return client.AddPermissionOverwriteAsync(channelId, affectedId, type, allow, deny).GetAwaiter().GetResult(); } - public static async Task RemovePermissionOverwriteAsync(this DiscordClient client, ulong channelId, ulong affectedId) { await client.HttpClient.DeleteAsync($"/channels/{channelId}/permissions/{affectedId}"); @@ -100,7 +97,6 @@ public static async Task CreateStageInstanceAsync(this Dis public static DiscordStageInstance CreateStageInstance(this DiscordClient client, ulong channelId, string topic, StagePrivacyLevel privacyLevel = StagePrivacyLevel.GuildOnly) => client.CreateStageInstanceAsync(channelId, topic, privacyLevel).GetAwaiter().GetResult(); - public static Task DeleteStageInstanceAsync(this DiscordClient client, ulong channelId) => client.HttpClient.DeleteAsync("/stage-instances/" + channelId); public static void DeleteStageInstance(this DiscordClient client, ulong channelId) => client.DeleteStageInstanceAsync(channelId).GetAwaiter().GetResult(); diff --git a/Anarchy/REST/Channel/Guild/Guild/GuildChannel.cs b/Anarchy/REST/Channel/Guild/Guild/GuildChannel.cs index 4c61de40..ea07d9a7 100644 --- a/Anarchy/REST/Channel/Guild/Guild/GuildChannel.cs +++ b/Anarchy/REST/Channel/Guild/Guild/GuildChannel.cs @@ -25,19 +25,15 @@ internal ulong GuildId public MinimalGuild Guild { get; private set; } - [JsonProperty("position")] public uint Position { get; protected set; } - [JsonProperty("parent_id")] public ulong? ParentId { get; protected set; } - [JsonProperty("permission_overwrites")] public IReadOnlyList PermissionOverwrites { get; protected set; } - protected void Update(GuildChannel channel) { base.Update(channel); @@ -46,10 +42,9 @@ protected void Update(GuildChannel channel) PermissionOverwrites = channel.PermissionOverwrites; } - public new async Task UpdateAsync() { - Update((GuildChannel)await Client.GetChannelAsync(Id)); + Update((GuildChannel) await Client.GetChannelAsync(Id)); } /// @@ -60,7 +55,6 @@ protected void Update(GuildChannel channel) UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(GuildChannelProperties properties) { Update(await Client.ModifyGuildChannelAsync(Id, properties)); @@ -75,7 +69,6 @@ public void Modify(GuildChannelProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task AddPermissionOverwriteAsync(ulong affectedId, PermissionOverwriteType type, DiscordPermission allow, DiscordPermission deny) { var overwrite = await Client.AddPermissionOverwriteAsync(Id, affectedId, type, allow, deny); @@ -99,7 +92,6 @@ public void AddPermissionOverwrite(ulong affectedId, PermissionOverwriteType typ AddPermissionOverwriteAsync(affectedId, type, allow, deny).GetAwaiter().GetResult(); } - public async Task RemovePermissionOverwriteAsync(ulong affectedId) { await Client.RemovePermissionOverwriteAsync(Id, affectedId); @@ -122,7 +114,6 @@ public void RemovePermissionOverwrite(ulong affectedId) RemovePermissionOverwriteAsync(affectedId).GetAwaiter().GetResult(); } - public string AsMessagable() { return $"<#{Id}>"; diff --git a/Anarchy/REST/Channel/Guild/Guild/GuildChannelProperties.cs b/Anarchy/REST/Channel/Guild/Guild/GuildChannelProperties.cs index a8b7e5ac..fb44165d 100644 --- a/Anarchy/REST/Channel/Guild/Guild/GuildChannelProperties.cs +++ b/Anarchy/REST/Channel/Guild/Guild/GuildChannelProperties.cs @@ -20,7 +20,6 @@ public bool ShouldSerializeName() return NameProperty.Set; } - private readonly DiscordParameter ParentProperty = new DiscordParameter(); [JsonProperty("parent_id")] public ulong? ParentId @@ -34,7 +33,6 @@ public bool ShouldSerializeParentId() return ParentProperty.Set; } - private readonly DiscordParameter PositionProperty = new DiscordParameter(); [JsonProperty("position")] public uint Position @@ -43,7 +41,6 @@ public uint Position set { PositionProperty.Value = value; } } - public bool ShouldSerializePosition() { return PositionProperty.Set; diff --git a/Anarchy/REST/Channel/Guild/Stage/DiscordStageInstance.cs b/Anarchy/REST/Channel/Guild/Stage/DiscordStageInstance.cs index 4d7b1f44..5e7fdeb2 100644 --- a/Anarchy/REST/Channel/Guild/Stage/DiscordStageInstance.cs +++ b/Anarchy/REST/Channel/Guild/Stage/DiscordStageInstance.cs @@ -28,7 +28,6 @@ public class DiscordStageInstance : Controllable [JsonProperty("invite_code")] public string InviteCode { get; private set; } - public Task SetClientSpeakingAsync(bool speaker) => Client.SetClientStageSpeakingAsync(_guildId, _channelId, speaker); public void SetClientSpeaking(bool speaker) => SetClientSpeakingAsync(speaker).GetAwaiter().GetResult(); diff --git a/Anarchy/REST/Channel/Guild/Stage/StageChannel.cs b/Anarchy/REST/Channel/Guild/Stage/StageChannel.cs index 150b24fd..0d920457 100644 --- a/Anarchy/REST/Channel/Guild/Stage/StageChannel.cs +++ b/Anarchy/REST/Channel/Guild/Stage/StageChannel.cs @@ -17,6 +17,5 @@ public Task CreateInstanceAsync(string topic, StagePrivacy public DiscordStageInstance CreateInstance(string topic, StagePrivacyLevel privacyLevel = StagePrivacyLevel.GuildOnly) => CreateInstanceAsync(topic, privacyLevel).GetAwaiter().GetResult(); - } } diff --git a/Anarchy/REST/Channel/Guild/Text/TextChannel.cs b/Anarchy/REST/Channel/Guild/Text/TextChannel.cs index da17b7a8..dcda8050 100644 --- a/Anarchy/REST/Channel/Guild/Text/TextChannel.cs +++ b/Anarchy/REST/Channel/Guild/Text/TextChannel.cs @@ -13,15 +13,12 @@ public class TextChannel : GuildChannel, IMessageChannel [JsonProperty("topic")] public string Topic { get; private set; } - [JsonProperty("nsfw")] public bool Nsfw { get; private set; } - [JsonProperty("last_message_id")] public ulong? LastMessageId { get; private set; } - private int _slowMode; [JsonProperty("rate_limit_per_user")] public int SlowMode @@ -30,7 +27,6 @@ public int SlowMode private set { _slowMode = value * 10; } //convert to milliseconds } - protected void Update(TextChannel channel) { base.Update(channel); @@ -40,10 +36,9 @@ protected void Update(TextChannel channel) SlowMode = channel.SlowMode; } - public new async Task UpdateAsync() { - Update((TextChannel)await Client.GetChannelAsync(Id)); + Update((TextChannel) await Client.GetChannelAsync(Id)); } /// @@ -54,7 +49,6 @@ protected void Update(TextChannel channel) UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(TextChannelProperties properties) { Update(await Client.ModifyGuildChannelAsync(Id, properties)); @@ -72,7 +66,6 @@ public void Modify(TextChannelProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - #region messages public async Task TriggerTypingAsync() { @@ -123,7 +116,6 @@ public DiscordMessage SendMessage(EmbedMaker embed) return SendMessageAsync(embed).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string fileName, byte[] fileData, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, fileName, fileData, message, tts); @@ -134,7 +126,6 @@ public DiscordMessage SendFile(string fileName, byte[] fileData, string message return SendFileAsync(fileName, fileData, message, tts).Result; } - public async Task SendFileAsync(string filePath, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, filePath, message, tts); @@ -145,7 +136,6 @@ public DiscordMessage SendFile(string filePath, string message = null, bool tts return SendFileAsync(filePath, message, tts).Result; } - public async Task DeleteMessagesAsync(List messages) { await Client.DeleteMessagesAsync(Id, messages); @@ -161,7 +151,6 @@ public void DeleteMessages(List messages) DeleteMessagesAsync(messages).GetAwaiter().GetResult(); } - public async Task> GetMessagesAsync(MessageFilters filters = null) { return await Client.GetChannelMessagesAsync(Id, filters); @@ -176,7 +165,6 @@ public IReadOnlyList GetMessages(MessageFilters filters = null) return GetMessagesAsync(filters).GetAwaiter().GetResult(); } - public async Task> GetPinnedMessagesAsync() { return await Client.GetPinnedMessagesAsync(Id); @@ -190,7 +178,6 @@ public IReadOnlyList GetPinnedMessages() return GetPinnedMessagesAsync().Result; } - public async Task PinMessageAsync(ulong messageId) { await Client.PinMessageAsync(Id, messageId); @@ -205,7 +192,6 @@ public void PinMessage(ulong messageId) PinMessageAsync(messageId).GetAwaiter().GetResult(); } - public async Task UnpinMessageAsync(ulong messageId) { await Client.UnpinChannelMessageAsync(Id, messageId); @@ -221,7 +207,6 @@ public void UnpinMessage(ulong messageId) } #endregion - public async Task FollowAsync(ulong crosspostChannelId) { return await Client.FollowChannelAsync(Id, crosspostChannelId); @@ -235,7 +220,6 @@ public ulong Follow(ulong crosspostChannelId) return FollowAsync(crosspostChannelId).GetAwaiter().GetResult(); } - public async Task CreateInviteAsync(InviteProperties properties = null) { return await Client.CreateInviteAsync(Id, properties); @@ -251,7 +235,6 @@ public DiscordInvite CreateInvite(InviteProperties properties = null) return CreateInviteAsync(properties).GetAwaiter().GetResult(); } - public async Task> GetWebhooksAsync() { return await Client.GetChannelWebhooksAsync(Id); @@ -265,7 +248,6 @@ public IReadOnlyList GetWebhooks() return GetWebhooksAsync().GetAwaiter().GetResult(); } - public async Task CreateWebhookAsync(DiscordWebhookProperties properties) { return await Client.CreateWebhookAsync(Id, properties); @@ -281,21 +263,18 @@ public DiscordDefaultWebhook CreateWebhook(DiscordWebhookProperties properties) return CreateWebhookAsync(properties).Result; } - public Task CreateThreadAsync(ulong messageId, string name, TimeSpan ttl) => Client.CreateThreadAsync(Id, messageId, name, ttl); public DiscordThread CreateThread(ulong messageId, string name, TimeSpan ttl) => CreateThreadAsync(messageId, name, ttl).GetAwaiter().GetResult(); - public Task CreateThreadAsync(string name, TimeSpan ttl) => Client.CreateThreadAsync(Id, name, ttl); public DiscordThread CreateThread(string name, TimeSpan ttl) => CreateThreadAsync(name, ttl).GetAwaiter().GetResult(); - internal override void SetLastMessageId(ulong id) { LastMessageId = id; diff --git a/Anarchy/REST/Channel/Guild/Text/TextChannelProperties.cs b/Anarchy/REST/Channel/Guild/Text/TextChannelProperties.cs index ee14d70d..351e094e 100644 --- a/Anarchy/REST/Channel/Guild/Text/TextChannelProperties.cs +++ b/Anarchy/REST/Channel/Guild/Text/TextChannelProperties.cs @@ -33,13 +33,11 @@ public string Topic set { TopicProperty.Value = value; } } - public bool ShouldSerializeTopic() { return TopicProperty.Set; } - private readonly DiscordParameter NsfwProperty = new DiscordParameter(); [JsonProperty("nsfw")] public bool Nsfw @@ -48,13 +46,11 @@ public bool Nsfw set { NsfwProperty.Value = value; } } - public bool ShouldSerializeNsfw() { return NsfwProperty.Set; } - private readonly DiscordParameter SlowModeProperty = new DiscordParameter(); [JsonProperty("rate_limit_per_user")] public int SlowMode @@ -63,7 +59,6 @@ public int SlowMode set { SlowModeProperty.Value = value; } } - public bool ShouldSerializeSlowMode() { return SlowModeProperty.Set; diff --git a/Anarchy/REST/Channel/Guild/Voice/VoiceChannel.cs b/Anarchy/REST/Channel/Guild/Voice/VoiceChannel.cs index 2c88ab09..1afc8658 100644 --- a/Anarchy/REST/Channel/Guild/Voice/VoiceChannel.cs +++ b/Anarchy/REST/Channel/Guild/Voice/VoiceChannel.cs @@ -11,11 +11,9 @@ public class VoiceChannel : GuildChannel [JsonProperty("bitrate")] public uint Bitrate { get; private set; } - [JsonProperty("user_limit")] public uint UserLimit { get; private set; } - protected void Update(VoiceChannel channel) { base.Update(channel); @@ -23,10 +21,9 @@ protected void Update(VoiceChannel channel) UserLimit = channel.UserLimit; } - public new async Task UpdateAsync() { - Update((VoiceChannel)await Client.GetChannelAsync(Id)); + Update((VoiceChannel) await Client.GetChannelAsync(Id)); } /// @@ -37,7 +34,6 @@ protected void Update(VoiceChannel channel) UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(VoiceChannelProperties properties) { Update(await Client.ModifyGuildChannelAsync(Id, properties)); @@ -52,7 +48,6 @@ public void Modify(VoiceChannelProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task CreateInviteAsync(InviteProperties properties = null) { return await Client.CreateInviteAsync(Id, properties); diff --git a/Anarchy/REST/Channel/Guild/Voice/VoiceChannelProperties.cs b/Anarchy/REST/Channel/Guild/Voice/VoiceChannelProperties.cs index efe5d3d7..5795c72c 100644 --- a/Anarchy/REST/Channel/Guild/Voice/VoiceChannelProperties.cs +++ b/Anarchy/REST/Channel/Guild/Voice/VoiceChannelProperties.cs @@ -15,13 +15,11 @@ public uint Bitrate set { BitrateProperty.Value = value; } } - public bool ShouldSerializeBitrate() { return BitrateProperty.Set; } - private readonly DiscordParameter UserLimitProperty = new DiscordParameter(); [JsonProperty("user_limit")] public uint UserLimit @@ -30,7 +28,6 @@ public uint UserLimit set { UserLimitProperty.Value = value; } } - public bool ShouldSerializeUserLimit() { return UserLimitProperty.Set; diff --git a/Anarchy/REST/Channel/Private/DM/Extensions.cs b/Anarchy/REST/Channel/Private/DM/Extensions.cs index 8f9973e3..8661f1fd 100644 --- a/Anarchy/REST/Channel/Private/DM/Extensions.cs +++ b/Anarchy/REST/Channel/Private/DM/Extensions.cs @@ -19,7 +19,6 @@ public static IReadOnlyList GetPrivateChannels(this DiscordClien return client.GetPrivateChannelsAsync().GetAwaiter().GetResult(); } - public static async Task CreateDMAsync(this DiscordClient client, ulong recipientId) { return (await client.HttpClient.PostAsync($"/users/@me/channels", $"{{\"recipient_id\":\"{recipientId}\"}}")) @@ -36,7 +35,6 @@ public static PrivateChannel CreateDM(this DiscordClient client, ulong recipient return client.CreateDMAsync(recipientId).GetAwaiter().GetResult(); } - public static async Task ChangePrivateCallRegionAsync(this DiscordClient client, ulong channelId, string regionId) { await client.HttpClient.PatchAsync($"/channels/{channelId}/call", $"{{\"region\":\"{regionId}\"}}"); diff --git a/Anarchy/REST/Channel/Private/DM/PrivateChannel.cs b/Anarchy/REST/Channel/Private/DM/PrivateChannel.cs index 8e629511..2e8f6f0e 100644 --- a/Anarchy/REST/Channel/Private/DM/PrivateChannel.cs +++ b/Anarchy/REST/Channel/Private/DM/PrivateChannel.cs @@ -18,27 +18,23 @@ public PrivateChannel() [JsonProperty("recipients")] internal ConcurrentList _recipients; - public IReadOnlyList Recipients { get { return _recipients; } } - [JsonProperty("last_message_id")] public ulong? LastMessageId { get; internal set; } - internal void Update(PrivateChannel channel) { base.Update(channel); _recipients = channel._recipients; } - public new async Task UpdateAsync() { - Update((PrivateChannel)await Client.GetChannelAsync(Id)); + Update((PrivateChannel) await Client.GetChannelAsync(Id)); } /// @@ -49,7 +45,6 @@ internal void Update(PrivateChannel channel) UpdateAsync().GetAwaiter().GetResult(); } - public async Task LeaveAsync() { await Client.DeleteChannelAsync(Id); @@ -63,7 +58,6 @@ public void Leave() LeaveAsync().GetAwaiter().GetResult(); } - public async Task ChangeCallRegionAsync(string regionId) { await Client.ChangePrivateCallRegionAsync(Id, regionId); @@ -74,7 +68,6 @@ public void ChangeCallRegion(string regionId) ChangeCallRegionAsync(regionId).GetAwaiter().GetResult(); } - #region messages public async Task TriggerTypingAsync() { @@ -89,7 +82,6 @@ public void TriggerTyping() TriggerTypingAsync().GetAwaiter().GetResult(); } - public Task SendMessageAsync(MessageProperties properties) { return Client.SendMessageAsync(Id, properties); @@ -126,7 +118,6 @@ public DiscordMessage SendMessage(EmbedMaker embed) return SendMessageAsync(embed).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string fileName, byte[] fileData, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, fileName, fileData, message, tts); @@ -137,7 +128,6 @@ public DiscordMessage SendFile(string fileName, byte[] fileData, string message return SendFileAsync(fileName, fileData, message, tts).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string filePath, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, filePath, message, tts); @@ -148,7 +138,6 @@ public DiscordMessage SendFile(string filePath, string message = null, bool tts return SendFileAsync(filePath, message, tts).GetAwaiter().GetResult(); } - public async Task DeleteMessagesAsync(List messages) { await Client.DeleteMessagesAsync(Id, messages); @@ -164,7 +153,6 @@ public void DeleteMessages(List messages) DeleteMessagesAsync(messages).GetAwaiter().GetResult(); } - public async Task> GetMessagesAsync(MessageFilters filters = null) { return await Client.GetChannelMessagesAsync(Id, filters); @@ -179,7 +167,6 @@ public IReadOnlyList GetMessages(MessageFilters filters = null) return GetMessagesAsync(filters).GetAwaiter().GetResult(); } - public async Task> GetPinnedMessagesAsync() { return await Client.GetPinnedMessagesAsync(Id); @@ -193,7 +180,6 @@ public IReadOnlyList GetPinnedMessages() return GetPinnedMessagesAsync().GetAwaiter().GetResult(); } - public async Task PinMessageAsync(ulong messageId) { await Client.PinMessageAsync(Id, messageId); @@ -208,7 +194,6 @@ public void PinMessage(ulong messageId) PinMessageAsync(messageId).GetAwaiter().GetResult(); } - public async Task UnpinMessageAsync(ulong messageId) { await Client.UnpinChannelMessageAsync(Id, messageId); diff --git a/Anarchy/REST/Channel/Private/Group/DiscordGroup.cs b/Anarchy/REST/Channel/Private/Group/DiscordGroup.cs index 69d2af94..901d821c 100644 --- a/Anarchy/REST/Channel/Private/Group/DiscordGroup.cs +++ b/Anarchy/REST/Channel/Private/Group/DiscordGroup.cs @@ -22,11 +22,9 @@ public DiscordCDNImage Icon } } - [JsonProperty("owner_id")] public ulong OwnerId { get; private set; } - protected void Update(DiscordGroup group) { base.Update(group); @@ -34,10 +32,9 @@ protected void Update(DiscordGroup group) OwnerId = group.OwnerId; } - public new async Task UpdateAsync() { - Update((DiscordGroup)await Client.GetChannelAsync(Id)); + Update((DiscordGroup) await Client.GetChannelAsync(Id)); } /// @@ -48,7 +45,6 @@ protected void Update(DiscordGroup group) UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(GroupProperties properties) { Update(await Client.ModifyGroupAsync(Id, properties)); @@ -63,7 +59,6 @@ public void Modify(GroupProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task AddRecipientAsync(ulong userId) { await Client.AddUserToGroupAsync(Id, userId); @@ -78,7 +73,6 @@ public void AddRecipient(ulong userId) AddRecipientAsync(userId).GetAwaiter().GetResult(); } - public async Task RemoveRecipientAsync(ulong userId) { await Client.RemoveUserFromGroupAsync(Id, userId); @@ -93,7 +87,6 @@ public void RemoveRecipient(ulong userId) RemoveRecipientAsync(userId).GetAwaiter().GetResult(); } - public async Task CreateInviteAsync() { return await Client.CreateInviteAsync(Id, new InviteProperties() { MaxAge = 10800 }); diff --git a/Anarchy/REST/Channel/Private/Group/Extensions.cs b/Anarchy/REST/Channel/Private/Group/Extensions.cs index 49c2ec02..152d0a47 100644 --- a/Anarchy/REST/Channel/Private/Group/Extensions.cs +++ b/Anarchy/REST/Channel/Private/Group/Extensions.cs @@ -22,7 +22,6 @@ public static DiscordInvite JoinGroup(this DiscordClient client, string inviteCo return client.JoinGroupAsync(inviteCode).GetAwaiter().GetResult(); } - public static async Task CreateGroupAsync(this DiscordClient client, List recipients) { return (await client.HttpClient.PostAsync($"/users/@me/channels", new JObject() @@ -41,10 +40,9 @@ public static DiscordGroup CreateGroup(this DiscordClient client, List re return client.CreateGroupAsync(recipients).GetAwaiter().GetResult(); } - public static async Task LeaveGroupAsync(this DiscordClient client, ulong groupId) { - return (DiscordGroup)await client.DeleteChannelAsync(groupId); + return (DiscordGroup) await client.DeleteChannelAsync(groupId); } public static DiscordGroup LeaveGroup(this DiscordClient client, ulong groupId) @@ -52,7 +50,6 @@ public static DiscordGroup LeaveGroup(this DiscordClient client, ulong groupId) return client.LeaveGroupAsync(groupId).GetAwaiter().GetResult(); } - public static async Task AddUserToGroupAsync(this DiscordClient client, ulong groupId, ulong userId) { await client.HttpClient.PutAsync($"/channels/{groupId}/recipients/{userId}"); @@ -68,7 +65,6 @@ public static void AddUserToGroup(this DiscordClient client, ulong groupId, ulon client.AddUserToGroupAsync(groupId, userId).GetAwaiter().GetResult(); } - public static async Task RemoveUserFromGroupAsync(this DiscordClient client, ulong groupId, ulong userId) { await client.HttpClient.DeleteAsync($"/channels/{groupId}/recipients/{userId}"); diff --git a/Anarchy/REST/Channel/Private/Group/GroupProperties.cs b/Anarchy/REST/Channel/Private/Group/GroupProperties.cs index 0467cd7a..2fdf8955 100644 --- a/Anarchy/REST/Channel/Private/Group/GroupProperties.cs +++ b/Anarchy/REST/Channel/Private/Group/GroupProperties.cs @@ -15,7 +15,6 @@ public string Name set { NameProperty.Value = value; } } - public bool ShouldSerializeName() { return NameProperty.Set; @@ -29,7 +28,6 @@ public DiscordImage Icon set { IconProperty.Value = value; } } - public bool ShouldSerializeIcon() { return IconProperty.Set; diff --git a/Anarchy/REST/DiscordClient.cs b/Anarchy/REST/DiscordClient.cs index dc8464b3..61db8826 100644 --- a/Anarchy/REST/DiscordClient.cs +++ b/Anarchy/REST/DiscordClient.cs @@ -38,13 +38,11 @@ public string Token } } - protected DiscordClient() { HttpClient = new DiscordHttpClient(this); } - public DiscordClient(ApiConfig config = null) : this() { if (config == null) diff --git a/Anarchy/REST/Discovery/DiscoveryGuild.cs b/Anarchy/REST/Discovery/DiscoveryGuild.cs index c57c54ea..5c499acd 100644 --- a/Anarchy/REST/Discovery/DiscoveryGuild.cs +++ b/Anarchy/REST/Discovery/DiscoveryGuild.cs @@ -11,23 +11,18 @@ public class DiscoveryGuild : BaseGuild [JsonProperty("description")] public string Description { get; protected set; } - [JsonProperty("approximate_presence_count")] public int OnlineMembers { get; private set; } - [JsonProperty("approximate_member_count")] public int Members { get; private set; } - [JsonProperty("premium_subscription_count")] public int PremiumSubscriptions { get; private set; } - [JsonProperty("preferred_locale")] public DiscordLanguage PreferredLanguage { get; private set; } - [JsonProperty("discovery_splash")] private readonly string _discoverySplashHash; @@ -42,23 +37,19 @@ public DiscordCDNImage DiscoverySplash } } - [JsonProperty("emojis")] public IReadOnlyList Emojis { get; private set; } - [JsonProperty("keywords")] public IReadOnlyList Keywords { get; private set; } - [JsonProperty("vanity_url_code")] public string VanityInvite { get; private set; } - public async Task LurkAsync() { if (Client.GetType() == typeof(DiscordSocketClient)) - return await ((DiscordSocketClient)Client).LurkGuildAsync(Id); + return await ((DiscordSocketClient) Client).LurkGuildAsync(Id); else throw new NotSupportedException("This method is only available for socket clients."); } diff --git a/Anarchy/REST/Discovery/Extensions.cs b/Anarchy/REST/Discovery/Extensions.cs index e8792231..aa985666 100644 --- a/Anarchy/REST/Discovery/Extensions.cs +++ b/Anarchy/REST/Discovery/Extensions.cs @@ -16,7 +16,7 @@ public static async Task QueryGuildsAsync(this DiscordClient c query += "&query=" + options.Query; if (options.Category.HasValue) - query += "&categories=" + (int)options.Category; + query += "&categories=" + (int) options.Category; return (await client.HttpClient.GetAsync($"/discoverable-guilds" + query)).Deserialize().SetClient(client); } @@ -29,7 +29,6 @@ public static GuildQueryResult QueryGuilds(this DiscordClient client, GuildQuery return client.QueryGuildsAsync(options).GetAwaiter().GetResult(); } - public static async Task LurkGuildAsync(this DiscordSocketClient client, ulong guildId) { client.Lurking = guildId; @@ -54,7 +53,6 @@ public static DiscordGuild LurkGuild(this DiscordSocketClient client, ulong guil return client.LurkGuildAsync(guildId).GetAwaiter().GetResult(); } - public static async Task JoinGuildAsync(this DiscordClient client, ulong guildId) { return (await client.HttpClient.PutAsync($"/guilds/{guildId}/members/@me?lurker=false")) diff --git a/Anarchy/REST/Discovery/GuildQueryResult.cs b/Anarchy/REST/Discovery/GuildQueryResult.cs index 8e6083e3..333373b0 100644 --- a/Anarchy/REST/Discovery/GuildQueryResult.cs +++ b/Anarchy/REST/Discovery/GuildQueryResult.cs @@ -16,7 +16,6 @@ public GuildQueryResult() [JsonProperty("total")] public uint Total { get; private set; } - [JsonProperty("guilds")] public IReadOnlyList Guilds { get; private set; } } diff --git a/Anarchy/REST/Embed/Author.cs b/Anarchy/REST/Embed/Author.cs index c59ce445..8587ab1f 100644 --- a/Anarchy/REST/Embed/Author.cs +++ b/Anarchy/REST/Embed/Author.cs @@ -19,19 +19,15 @@ public string Name } } - [JsonProperty("url")] public string Url { get; set; } - [JsonProperty("icon_url")] public string IconUrl { get; set; } - [JsonProperty("proxy_icon_url")] public string IconProxyUrl { get; private set; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Embed/DiscordEmbed.cs b/Anarchy/REST/Embed/DiscordEmbed.cs index 2868ee3b..e4857404 100644 --- a/Anarchy/REST/Embed/DiscordEmbed.cs +++ b/Anarchy/REST/Embed/DiscordEmbed.cs @@ -16,56 +16,44 @@ public DiscordEmbed() Author = new EmbedAuthor(); } - [JsonProperty("title")] public string Title { get; internal set; } - [JsonProperty("url")] public string TitleUrl { get; set; } - [JsonProperty("description")] public string Description { get; internal set; } - [JsonProperty("color")] private uint _color; public Color Color { - get { return Color.FromArgb((int)_color); } - set { _color = (uint)Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } + get { return Color.FromArgb((int) _color); } + set { _color = (uint) Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } } - [JsonProperty("fields")] public IReadOnlyList Fields { get; internal set; } - [JsonProperty("video")] public EmbedVideo Video { get; private set; } - [JsonProperty("thumbnail")] public EmbedImage Thumbnail { get; private set; } - [JsonProperty("image")] public EmbedImage Image { get; private set; } - [JsonProperty("footer")] public EmbedFooter Footer { get; internal set; } - [JsonProperty("author")] public EmbedAuthor Author { get; internal set; } - [JsonProperty("timestamp")] public DateTime? Timestamp { get; internal set; } - public override string ToString() { return Title; diff --git a/Anarchy/REST/Embed/EmbedException.cs b/Anarchy/REST/Embed/EmbedException.cs index 96869253..d8f36bb0 100644 --- a/Anarchy/REST/Embed/EmbedException.cs +++ b/Anarchy/REST/Embed/EmbedException.cs @@ -6,7 +6,6 @@ public class EmbedException : Exception { public EmbedError Error { get; private set; } - internal EmbedException(EmbedError error) : base(error.ToString()) { Error = error; diff --git a/Anarchy/REST/Embed/EmbedMaker.cs b/Anarchy/REST/Embed/EmbedMaker.cs index af393bf1..3c6a0b00 100644 --- a/Anarchy/REST/Embed/EmbedMaker.cs +++ b/Anarchy/REST/Embed/EmbedMaker.cs @@ -12,7 +12,6 @@ public class EmbedMaker { private readonly DiscordEmbed _embed; - public string Title { get { return _embed.Title; } @@ -25,14 +24,12 @@ public string Title } } - public string TitleUrl { get { return _embed.TitleUrl; } set { _embed.TitleUrl = value; } } - public string Description { get { return _embed.Description; } @@ -45,14 +42,12 @@ public string Description } } - public Color Color { get { return _embed.Color; } set { _embed.Color = value; } } - public EmbedMaker AddField(string name, string content, bool inline = false) { if (_embed.Fields.Count == 25) @@ -62,7 +57,6 @@ public EmbedMaker AddField(string name, string content, bool inline = false) if (content.Length > 1024) throw new EmbedException(EmbedError.FieldContentTooLong); - List fields = _embed.Fields.ToList(); fields.Add(new EmbedField(name, content, inline)); _embed.Fields = fields; @@ -70,55 +64,46 @@ public EmbedMaker AddField(string name, string content, bool inline = false) return this; } - public string ThumbnailUrl { get { return _embed.Thumbnail.Url; } set { _embed.Thumbnail.Url = value; } } - public string ImageUrl { get { return _embed.Image.Url; } set { _embed.Image.Url = value; } } - public EmbedFooter Footer { get { return _embed.Footer; } set { _embed.Footer = value; } } - public EmbedAuthor Author { get { return _embed.Author; } set { _embed.Author = value; } } - public DateTime? Timestamp { get { return _embed.Timestamp; } set { _embed.Timestamp = value; } } - public EmbedMaker() { _embed = new DiscordEmbed(); } - public static implicit operator DiscordEmbed(EmbedMaker instance) { return instance._embed; } - - public override string ToString() { return _embed.ToString(); diff --git a/Anarchy/REST/Embed/Field.cs b/Anarchy/REST/Embed/Field.cs index 5f9e2e28..479a7e1e 100644 --- a/Anarchy/REST/Embed/Field.cs +++ b/Anarchy/REST/Embed/Field.cs @@ -9,7 +9,6 @@ public EmbedField() } - internal EmbedField(string name, string content, bool inline) { Name = name; @@ -17,19 +16,15 @@ internal EmbedField(string name, string content, bool inline) Inline = inline; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("value")] public string Content { get; private set; } - [JsonProperty("inline")] public bool Inline { get; private set; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Embed/Footer.cs b/Anarchy/REST/Embed/Footer.cs index 23f8b3ad..e523a2f7 100644 --- a/Anarchy/REST/Embed/Footer.cs +++ b/Anarchy/REST/Embed/Footer.cs @@ -19,15 +19,12 @@ public string Text } } - [JsonProperty("icon_url")] public string IconUrl { get; set; } - [JsonProperty("proxy_icon_url")] public string IconProxyUrl { get; private set; } - public override string ToString() { return Text; diff --git a/Anarchy/REST/Embed/Image.cs b/Anarchy/REST/Embed/Image.cs index 1793dba5..090ec577 100644 --- a/Anarchy/REST/Embed/Image.cs +++ b/Anarchy/REST/Embed/Image.cs @@ -7,15 +7,12 @@ public class EmbedImage [JsonProperty("url")] public string Url { get; internal set; } - [JsonProperty("width")] public uint Width { get; private set; } - [JsonProperty("height")] public uint Height { get; private set; } - public override string ToString() { return $"W: {Width}, H: {Height}"; diff --git a/Anarchy/REST/Embed/Video.cs b/Anarchy/REST/Embed/Video.cs index 23b4abf7..8c2d384d 100644 --- a/Anarchy/REST/Embed/Video.cs +++ b/Anarchy/REST/Embed/Video.cs @@ -8,15 +8,12 @@ public class EmbedVideo [JsonProperty("url")] public string Url { get; private set; } - [JsonProperty("width")] public uint Width { get; private set; } - [JsonProperty("height")] public uint Height { get; private set; } - public override string ToString() { return $"W: {Width} H: {Height}"; diff --git a/Anarchy/REST/Emoji/Extentions.cs b/Anarchy/REST/Emoji/Extentions.cs index 19eb794d..5d3f500d 100644 --- a/Anarchy/REST/Emoji/Extentions.cs +++ b/Anarchy/REST/Emoji/Extentions.cs @@ -24,7 +24,6 @@ public static DiscordEmoji CreateEmoji(this DiscordClient client, ulong guildId, return client.CreateEmojiAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task ModifyEmojiAsync(this DiscordClient client, ulong guildId, ulong emojiId, string name) { return (await client.HttpClient.PatchAsync($"/guilds/{guildId}/emojis/{emojiId}", $"{{\"name\":\"{name}\"}}")) @@ -43,7 +42,6 @@ public static DiscordEmoji ModifyEmoji(this DiscordClient client, ulong guildId, return client.ModifyEmojiAsync(guildId, emojiId, name).GetAwaiter().GetResult(); } - public static async Task DeleteEmojiAsync(this DiscordClient client, ulong guildId, ulong emojiId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/emojis/{emojiId}"); @@ -60,7 +58,6 @@ public static void DeleteEmoji(this DiscordClient client, ulong guildId, ulong e } #endregion - public static async Task> GetGuildEmojisAsync(this DiscordClient client, ulong guildId) { var emojis = (await client.HttpClient.GetAsync($"/guilds/{guildId}/emojis")) @@ -78,7 +75,6 @@ public static IReadOnlyList GetGuildEmojis(this DiscordClient clie return client.GetGuildEmojisAsync(guildId).GetAwaiter().GetResult(); } - public static async Task GetGuildEmojiAsync(this DiscordClient client, ulong guildId, ulong emojiId) { DiscordEmoji reaction = (await client.HttpClient.GetAsync($"/guilds/{guildId}/emojis/{emojiId}")) diff --git a/Anarchy/REST/Emoji/Models/DiscordEmoji.cs b/Anarchy/REST/Emoji/Models/DiscordEmoji.cs index a7616ff7..d890a3d9 100644 --- a/Anarchy/REST/Emoji/Models/DiscordEmoji.cs +++ b/Anarchy/REST/Emoji/Models/DiscordEmoji.cs @@ -10,15 +10,12 @@ public DiscordEmoji() OnClientUpdated += (sender, e) => Creator.SetClient(Client); } - [JsonProperty("user")] public DiscordUser Creator { get; private set; } - [JsonProperty("available")] public bool Available { get; private set; } - internal ulong GuildId { get; set; } public MinimalGuild Guild @@ -36,7 +33,7 @@ private void Update(DiscordEmoji emoji) public async Task UpdateAsync() { - Update(await Client.GetGuildEmojiAsync(GuildId, (ulong)Id)); + Update(await Client.GetGuildEmojiAsync(GuildId, (ulong) Id)); } /// @@ -47,10 +44,9 @@ public void Update() UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(string name) { - Update(await Client.ModifyEmojiAsync(GuildId, (ulong)Id, name)); + Update(await Client.ModifyEmojiAsync(GuildId, (ulong) Id, name)); } /// @@ -62,10 +58,9 @@ public void Modify(string name) ModifyAsync(name).GetAwaiter().GetResult(); } - public async Task DeleteAsync() { - await Client.DeleteEmojiAsync(GuildId, (ulong)Id); + await Client.DeleteEmojiAsync(GuildId, (ulong) Id); } /// diff --git a/Anarchy/REST/Emoji/Models/EmojiContainer.cs b/Anarchy/REST/Emoji/Models/EmojiContainer.cs index ce043fd2..c6be9e9d 100644 --- a/Anarchy/REST/Emoji/Models/EmojiContainer.cs +++ b/Anarchy/REST/Emoji/Models/EmojiContainer.cs @@ -16,11 +16,9 @@ public EmojiContainer() }; } - [JsonProperty("guild_id")] public ulong GuildId { get; private set; } - [JsonProperty("emojis")] public IReadOnlyList Emojis { get; private set; } } diff --git a/Anarchy/REST/Emoji/Models/EmojiProperties.cs b/Anarchy/REST/Emoji/Models/EmojiProperties.cs index 68f6939b..6a78709f 100644 --- a/Anarchy/REST/Emoji/Models/EmojiProperties.cs +++ b/Anarchy/REST/Emoji/Models/EmojiProperties.cs @@ -10,7 +10,6 @@ public class EmojiProperties [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("image")] public DiscordImage Image { get; set; } diff --git a/Anarchy/REST/Emoji/Models/PartialEmoji.cs b/Anarchy/REST/Emoji/Models/PartialEmoji.cs index 027de0c1..a3191349 100644 --- a/Anarchy/REST/Emoji/Models/PartialEmoji.cs +++ b/Anarchy/REST/Emoji/Models/PartialEmoji.cs @@ -21,15 +21,12 @@ public PartialEmoji(ulong id, string name, bool animated) : this(name) [JsonProperty("id")] public ulong? Id { get; private set; } - [JsonProperty("name")] public string Name { get; protected set; } - [JsonProperty("animated")] public bool Animated { get; private set; } - public DiscordCDNImage Icon { get @@ -41,13 +38,11 @@ public DiscordCDNImage Icon } } - public bool Custom { get { return Id != null; } } - public string AsMessagable() { if (Custom) @@ -56,7 +51,6 @@ public string AsMessagable() throw new NotSupportedException("Emoji must be custom to be converted. To convert standard emojis, get their unicode character"); } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Gifts/DiscordGift.cs b/Anarchy/REST/Gifts/DiscordGift.cs index 09b6b227..e2fae0a4 100644 --- a/Anarchy/REST/Gifts/DiscordGift.cs +++ b/Anarchy/REST/Gifts/DiscordGift.cs @@ -7,23 +7,18 @@ public class DiscordGift : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("sku_id")] public ulong SkuId { get; private set; } - [JsonProperty("application_id")] public ulong ApplicationId { get; private set; } - [JsonProperty("user")] public DiscordUser Gifter { get; private set; } - [JsonProperty("consumed")] public bool Consumed { get; private set; } - [JsonProperty("subscription_plan")] public SubscriptionPlan SubscriptionPlan { get; private set; } } diff --git a/Anarchy/REST/Gifts/Extensions.cs b/Anarchy/REST/Gifts/Extensions.cs index 71cebe6c..9b39101b 100644 --- a/Anarchy/REST/Gifts/Extensions.cs +++ b/Anarchy/REST/Gifts/Extensions.cs @@ -24,7 +24,6 @@ public static string PurchaseGift(this DiscordClient client, ulong paymentMethod return client.PurchaseGiftAsync(paymentMethodId, skuId, subPlanId, expectedAmount).GetAwaiter().GetResult(); } - public static async Task> GetGiftInventoryAsync(this DiscordClient client) { return (await client.HttpClient.GetAsync("/users/@me/entitlements/gifts")).Deserialize>(); @@ -35,7 +34,6 @@ public static IReadOnlyList GetGiftInventory(this DiscordClient cli return client.GetGiftInventoryAsync().GetAwaiter().GetResult(); } - public static async Task> QueryGiftCodesAsync(this DiscordClient client, ulong skuId, ulong subPlanId) { return (await client.HttpClient.GetAsync($"/users/@me/entitlements/gift-codes?sku_id={skuId}&subscription_plan_id={subPlanId}")) @@ -47,7 +45,6 @@ public static IReadOnlyList QueryGiftCodes(this DiscordCl return client.QueryGiftCodesAsync(skuId, subPlanId).GetAwaiter().GetResult(); } - public static async Task CreateGiftCodeAsync(this DiscordClient client, ulong skuId, ulong subPlanId) { return (await client.HttpClient.PostAsync("/users/@me/entitlements/gift-codes", $"{{\"sku_id\":{skuId},\"subscription_plan_id\":{subPlanId}}}")) @@ -59,7 +56,6 @@ public static RedeemableDiscordGift CreateGiftCode(this DiscordClient client, ul return client.CreateGiftCodeAsync(skuId, subPlanId).GetAwaiter().GetResult(); } - public static async Task RevokeGiftCodeAsync(this DiscordClient client, string code) { await client.HttpClient.DeleteAsync("/@me/entitlements/gift-codes/" + code); @@ -70,7 +66,6 @@ public static void RevokeGiftCode(this DiscordClient client, string code) client.RevokeGiftCodeAsync(code).GetAwaiter().GetResult(); } - public static async Task RedeemGiftAsync(this DiscordClient client, string code, ulong? channelId = null) { await client.HttpClient.PostAsync($"/entitlements/gift-codes/{code}/redeem", channelId.HasValue ? $"{{\"channel_id\":{channelId.Value}}}" : null); @@ -81,7 +76,6 @@ public static void RedeemGift(this DiscordClient client, string code, ulong? cha client.RedeemGiftAsync(code, channelId).GetAwaiter().GetResult(); } - public static async Task GetGiftAsync(this DiscordClient client, string code) { return (await client.HttpClient.GetAsync($"/entitlements/gift-codes/{code}?with_application=false&with_subscription_plan=true")) @@ -93,7 +87,6 @@ public static RedeemableDiscordGift GetGift(this DiscordClient client, string co return client.GetGiftAsync(code).GetAwaiter().GetResult(); } - public static async Task PurchaseNitroGiftAsync(this DiscordClient client, ulong paymentMethodId, DiscordNitroSubType type) { return await client.PurchaseGiftAsync(paymentMethodId, type.SkuId, type.SubscriptionPlanId, type.ExpectedAmount); diff --git a/Anarchy/REST/Gifts/PurchaseOptions.cs b/Anarchy/REST/Gifts/PurchaseOptions.cs index e7c3ea9c..47ffbb0b 100644 --- a/Anarchy/REST/Gifts/PurchaseOptions.cs +++ b/Anarchy/REST/Gifts/PurchaseOptions.cs @@ -7,17 +7,14 @@ public class PurchaseOptions [JsonProperty("expected_amount")] public int ExpectedAmount { get; set; } - [JsonProperty("gift")] #pragma warning disable CS0414 private readonly bool _gift = true; // rn we only have support for gifts kek #pragma warning restore CS0414 - [JsonProperty("payment_source_id")] public ulong PaymentMethodId { get; set; } - [JsonProperty("sku_subscription_plan_id")] public ulong SkuPlanId { get; set; } } diff --git a/Anarchy/REST/Gifts/RedeemableDiscordGift.cs b/Anarchy/REST/Gifts/RedeemableDiscordGift.cs index 4c2a1cb4..900f1041 100644 --- a/Anarchy/REST/Gifts/RedeemableDiscordGift.cs +++ b/Anarchy/REST/Gifts/RedeemableDiscordGift.cs @@ -9,23 +9,18 @@ public class RedeemableDiscordGift : DiscordGift [JsonProperty("code")] public string Code { get; private set; } - [JsonProperty("expires_at")] public DateTime ExpiresAt { get; private set; } - [JsonProperty("redeemed")] public bool Redeemed { get; private set; } - [JsonProperty("uses")] public uint Uses { get; private set; } - [JsonProperty("max_uses")] public uint MaxUses { get; private set; } - public async Task RedeemAsync(ulong? channelId = null) { await Client.RedeemGiftAsync(Code, channelId); @@ -36,7 +31,6 @@ public void Redeem(ulong? channelId = null) RedeemAsync(channelId).GetAwaiter().GetResult(); } - public async Task RevokeAsync() { await Client.RevokeGiftCodeAsync(Code); diff --git a/Anarchy/REST/Guild/AuditLog/Extensions.cs b/Anarchy/REST/Guild/AuditLog/Extensions.cs index 87068b68..bf18f42d 100644 --- a/Anarchy/REST/Guild/AuditLog/Extensions.cs +++ b/Anarchy/REST/Guild/AuditLog/Extensions.cs @@ -11,7 +11,7 @@ public static async Task> GetAuditLogAsync(this Dis if (filters == null) filters = new AuditLogFilters(); - return (await client.HttpClient.GetAsync($"/guilds/{guildId}/audit-logs?{(filters.UserIdProperty.Set ? $"user_id={filters.UserId}" : "")}&{(filters.ActionTypeProperty.Set ? $"action_type={(int)filters.ActionType}" : "")}&{(filters.BeforeIdProperty.Set ? $"before={filters.BeforeId}" : "")}&{(filters.LimitProperty.Set ? $"limit={filters.Limit}" : "")}")) + return (await client.HttpClient.GetAsync($"/guilds/{guildId}/audit-logs?{(filters.UserIdProperty.Set ? $"user_id={filters.UserId}" : "")}&{(filters.ActionTypeProperty.Set ? $"action_type={(int) filters.ActionType}" : "")}&{(filters.BeforeIdProperty.Set ? $"before={filters.BeforeId}" : "")}&{(filters.LimitProperty.Set ? $"limit={filters.Limit}" : "")}")) .Body.Value("audit_log_entries").ToObject>(); } diff --git a/Anarchy/REST/Guild/AuditLog/Models/Change.cs b/Anarchy/REST/Guild/AuditLog/Models/Change.cs index 307e48a6..b71af078 100644 --- a/Anarchy/REST/Guild/AuditLog/Models/Change.cs +++ b/Anarchy/REST/Guild/AuditLog/Models/Change.cs @@ -7,15 +7,12 @@ public class AuditLogChange [JsonProperty("new_value")] public dynamic NewValue { get; private set; } - [JsonProperty("old_value")] public dynamic OldValue { get; private set; } - [JsonProperty("key")] public string Key { get; private set; } - public override string ToString() { return Key; diff --git a/Anarchy/REST/Guild/AuditLog/Models/Entry.cs b/Anarchy/REST/Guild/AuditLog/Models/Entry.cs index 332e412b..29076f75 100644 --- a/Anarchy/REST/Guild/AuditLog/Models/Entry.cs +++ b/Anarchy/REST/Guild/AuditLog/Models/Entry.cs @@ -8,33 +8,26 @@ public class AuditLogEntry [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("target_id")] public ulong? TargetId { get; private set; } - [JsonProperty("changes")] public IReadOnlyList Changes { get; private set; } - [JsonProperty("user_id")] public ulong ChangerId { get; private set; } - [JsonProperty("action_type")] public AuditLogActionType Type { get; private set; } - [JsonProperty("reason")] public string Reason { get; private set; } - public override string ToString() { return Type.ToString(); } - public static implicit operator ulong(AuditLogEntry instance) { return instance.Id; diff --git a/Anarchy/REST/Guild/AuditLog/Models/Filters.cs b/Anarchy/REST/Guild/AuditLog/Models/Filters.cs index 85129794..6cf6dd31 100644 --- a/Anarchy/REST/Guild/AuditLog/Models/Filters.cs +++ b/Anarchy/REST/Guild/AuditLog/Models/Filters.cs @@ -9,7 +9,6 @@ public long UserId set { UserIdProperty.Value = value; } } - internal DiscordParameter ActionTypeProperty = new DiscordParameter(); public AuditLogActionType ActionType { @@ -17,7 +16,6 @@ public AuditLogActionType ActionType set { ActionTypeProperty.Value = value; } } - internal DiscordParameter BeforeIdProperty = new DiscordParameter(); public ulong BeforeId { @@ -25,7 +23,6 @@ public ulong BeforeId set { BeforeIdProperty.Value = value; } } - internal DiscordParameter LimitProperty = new DiscordParameter(); public uint Limit { diff --git a/Anarchy/REST/Guild/Community/CommunityExtensions.cs b/Anarchy/REST/Guild/Community/CommunityExtensions.cs index 0070fed0..10982814 100644 --- a/Anarchy/REST/Guild/Community/CommunityExtensions.cs +++ b/Anarchy/REST/Guild/Community/CommunityExtensions.cs @@ -16,7 +16,6 @@ public static WelcomeScreen GetWelcomeScreen(this DiscordClient client, ulong gu return client.GetWelcomeScreenAsync(guildId).GetAwaiter().GetResult(); } - public static async Task ModifyWelcomeScreenAsync(this DiscordClient client, ulong guildId, WelcomeScreenProperties properties) { return (await client.HttpClient.PatchAsync($"/guilds/{guildId}/welcome-screen", properties)) @@ -28,7 +27,6 @@ public static WelcomeScreen ModifyWelcomeScreen(this DiscordClient client, ulong return client.ModifyWelcomeScreenAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task GetGuildVerificationFormAsync(this DiscordClient client, ulong guildId, string inviteCode) { return (await client.HttpClient.GetAsync($"/guilds/{guildId}/member-verification?with_guild=false&invite_code={inviteCode}")) @@ -40,14 +38,12 @@ public static GuildVerificationForm GetGuildVerificationForm(this DiscordClient return client.GetGuildVerificationFormAsync(guildId, inviteCode).GetAwaiter().GetResult(); } - public static async Task ModifyGuildVerificationFormAsync(this DiscordClient client, ulong guildId, VerificationFormProperties properties) => (await client.HttpClient.PatchAsync($"/guilds/{guildId}/member-verification", properties)).Deserialize(); public static GuildVerificationForm ModifyGuildVerificationForm(this DiscordClient client, ulong guildId, VerificationFormProperties properties) => client.ModifyGuildVerificationFormAsync(guildId, properties).GetAwaiter().GetResult(); - public static async Task SubmitGuildVerificationFormAsync(this DiscordClient client, ulong guildId, string formVersion, List fields) { return (await client.HttpClient.PutAsync($"/guilds/{guildId}/requests/@me", new { version = formVersion, form_fields = fields })) diff --git a/Anarchy/REST/Guild/Community/Screening/VerificationFormProperties.cs b/Anarchy/REST/Guild/Community/Screening/VerificationFormProperties.cs index 1a2bebc6..0ac936ae 100644 --- a/Anarchy/REST/Guild/Community/Screening/VerificationFormProperties.cs +++ b/Anarchy/REST/Guild/Community/Screening/VerificationFormProperties.cs @@ -13,11 +13,9 @@ public string Description public bool ShouldSerializeDescription() => _descParam.Set; - public List Fields { get; set; } public bool ShouldSerializeFields() => Fields != null; - private readonly DiscordParameter _enabledParam = new DiscordParameter(); public bool Enabled { diff --git a/Anarchy/REST/Guild/Community/Screening/VerificationFormResponse.cs b/Anarchy/REST/Guild/Community/Screening/VerificationFormResponse.cs index fec5b28c..9db8e714 100644 --- a/Anarchy/REST/Guild/Community/Screening/VerificationFormResponse.cs +++ b/Anarchy/REST/Guild/Community/Screening/VerificationFormResponse.cs @@ -8,17 +8,14 @@ public class VerificationFormResponse : Controllable [JsonProperty("created_at")] public DateTime SubmittedAt { get; private set; } - [JsonProperty("rejection_reason")] public string RejectionReason { get; private set; } - [JsonProperty("application_status")] public string ApplicationStatus { get; private set; } public bool Approved => ApplicationStatus == "APPROVED"; - [JsonProperty("guild_id")] private ulong _guildId; diff --git a/Anarchy/REST/Guild/Community/WelcomeChannel.cs b/Anarchy/REST/Guild/Community/WelcomeChannel.cs index 901093f1..58eca4c3 100644 --- a/Anarchy/REST/Guild/Community/WelcomeChannel.cs +++ b/Anarchy/REST/Guild/Community/WelcomeChannel.cs @@ -15,11 +15,9 @@ public MinimalTextChannel Channel [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("emoji_id")] public ulong? EmojiId { get; private set; } - [JsonProperty("emoji_name")] public string EmojiName { get; private set; } } diff --git a/Anarchy/REST/Guild/Community/WelcomeChannelProperties.cs b/Anarchy/REST/Guild/Community/WelcomeChannelProperties.cs index 7952067f..33fb22b2 100644 --- a/Anarchy/REST/Guild/Community/WelcomeChannelProperties.cs +++ b/Anarchy/REST/Guild/Community/WelcomeChannelProperties.cs @@ -7,15 +7,12 @@ public class WelcomeChannelProperties [JsonProperty("channel_id")] public ulong ChannelId { get; set; } - [JsonProperty("description")] public string Description { get; set; } - [JsonProperty("emoji_id")] public ulong? EmojiId { get; set; } - [JsonProperty("emoji_name")] public string EmojiName { get; set; } } diff --git a/Anarchy/REST/Guild/Community/WelcomeScreen.cs b/Anarchy/REST/Guild/Community/WelcomeScreen.cs index efa51dae..03fdc6b4 100644 --- a/Anarchy/REST/Guild/Community/WelcomeScreen.cs +++ b/Anarchy/REST/Guild/Community/WelcomeScreen.cs @@ -16,7 +16,6 @@ public WelcomeScreen() [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("welcome_channels")] public IReadOnlyList Channels { get; private set; } } diff --git a/Anarchy/REST/Guild/Community/WelcomeScreenProperties.cs b/Anarchy/REST/Guild/Community/WelcomeScreenProperties.cs index 1586f830..b71baedf 100644 --- a/Anarchy/REST/Guild/Community/WelcomeScreenProperties.cs +++ b/Anarchy/REST/Guild/Community/WelcomeScreenProperties.cs @@ -18,7 +18,6 @@ public bool ShouldSerializeEnabled() return _enabled.Set; } - private readonly DiscordParameter> _channels = new DiscordParameter>(); [JsonProperty("welcome_channels")] public List Channels @@ -32,7 +31,6 @@ public bool ShouldSerializeChannels() return _channels.Set; } - private readonly DiscordParameter _description = new DiscordParameter(); [JsonProperty("description")] public string Description diff --git a/Anarchy/REST/Guild/Extensions.cs b/Anarchy/REST/Guild/Extensions.cs index cf569938..7a20ab63 100644 --- a/Anarchy/REST/Guild/Extensions.cs +++ b/Anarchy/REST/Guild/Extensions.cs @@ -31,7 +31,6 @@ public static DiscordGuild CreateGuild(this DiscordClient client, string name, D return client.CreateGuildAsync(name, icon, region).GetAwaiter().GetResult(); } - public static async Task ModifyGuildAsync(this DiscordClient client, ulong guildId, GuildProperties properties) { if (properties.VanityProperty.Set) @@ -51,7 +50,6 @@ public static DiscordGuild ModifyGuild(this DiscordClient client, ulong guildId, return client.ModifyGuildAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task DeleteGuildAsync(this DiscordClient client, ulong guildId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}"); @@ -66,7 +64,6 @@ public static void DeleteGuild(this DiscordClient client, ulong guildId) client.DeleteGuildAsync(guildId).GetAwaiter().GetResult(); } - public static async Task SetGuildVanityUrlAsync(this DiscordClient client, ulong guildId, string vanityCode) { await client.HttpClient.PatchAsync($"/guilds/{guildId}/vanity-url", $"{{\"code\":\"{vanityCode}\"}}"); @@ -77,7 +74,6 @@ public static void SetGuildVanityUrl(this DiscordClient client, ulong guildId, s client.SetGuildVanityUrlAsync(guildId, vanityCode).GetAwaiter().GetResult(); } - public static async Task> GetGuildBansAsync(this DiscordClient client, ulong guildId) { IReadOnlyList bans = (await client.HttpClient.GetAsync($"/guilds/{guildId}/bans")) @@ -96,7 +92,6 @@ public static IReadOnlyList GetGuildBans(this DiscordClient client, return client.GetGuildBansAsync(guildId).GetAwaiter().GetResult(); } - public static async Task GetGuildBanAsync(this DiscordClient client, ulong guildId, ulong userId) { DiscordBan ban = (await client.HttpClient.GetAsync($"/guilds/{guildId}/bans/{userId}")) @@ -116,7 +111,6 @@ public static DiscordBan GetGuildBan(this DiscordClient client, ulong guildId, u return client.GetGuildBanAsync(guildId, userId).GetAwaiter().GetResult(); } - public static async Task UnbanGuildMemberAsync(this DiscordClient client, ulong guildId, ulong userId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/bans/{userId}"); @@ -133,7 +127,6 @@ public static void UnbanGuildMember(this DiscordClient client, ulong guildId, ul } #endregion - public static async Task ModifyGuildSettingsAsync(this DiscordClient client, ulong guildId, GuildSettingsProperties properties) { return (await client.HttpClient.PatchAsync($"/users/@me/guilds/{guildId}/settings", properties)).Deserialize().SetClient(client); @@ -144,7 +137,6 @@ public static ClientGuildSettings ModifyGuildSettings(this DiscordClient client, return client.ModifyGuildSettingsAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task> SetPrivateChannelSettingsAsync(this DiscordClient client, Dictionary channels) { JObject container = new JObject @@ -160,7 +152,6 @@ public static IReadOnlyList SetPrivateChannelSettings(th return client.SetPrivateChannelSettingsAsync(channels).GetAwaiter().GetResult(); } - public static async Task> GetGuildsAsync(this DiscordClient client, uint limit = 100, ulong afterId = 0) { return (await client.HttpClient.GetAsync($"/users/@me/guilds?limit={limit}&after={afterId}")) @@ -177,7 +168,6 @@ public static IReadOnlyList GetGuilds(this DiscordClient client, u return client.GetGuildsAsync(limit, afterId).GetAwaiter().GetResult(); } - public static async Task GetGuildAsync(this DiscordClient client, ulong guildId) { return (await client.HttpClient.GetAsync("/guilds/" + guildId)) @@ -193,7 +183,6 @@ public static DiscordGuild GetGuild(this DiscordClient client, ulong guildId) return client.GetGuildAsync(guildId).GetAwaiter().GetResult(); } - public static async Task JoinGuildAsync(this DiscordClient client, string invCode, string captchaKey = null) { return (await client.HttpClient.PostAsync($"/invites/{invCode}", captchaKey != null ? $"{{\"captcha_key\":\"{captchaKey}\"}}" : null)) @@ -209,7 +198,6 @@ public static GuildInvite JoinGuild(this DiscordClient client, string invCode) return client.JoinGuildAsync(invCode).GetAwaiter().GetResult(); } - public static async Task LeaveGuildAsync(this DiscordClient client, ulong guildId, bool lurking = false) { await client.HttpClient.DeleteAsync($"/users/@me/guilds/{guildId}", $"{{\"lurking\":{lurking.ToString().ToLower()}}}"); @@ -224,7 +212,6 @@ public static void LeaveGuild(this DiscordClient client, ulong guildId, bool lur client.LeaveGuildAsync(guildId, lurking).GetAwaiter().GetResult(); } - public static async Task AcknowledgeGuildMessagesAsync(this DiscordClient client, ulong guildId) { await client.HttpClient.PostAsync($"/guilds/{guildId}/ack"); @@ -239,7 +226,6 @@ public static void AcknowledgeGuildMessages(this DiscordClient client, ulong gui client.AcknowledgeGuildMessagesAsync(guildId).GetAwaiter().GetResult(); } - public static async Task GetGoLivePreviewAsync(this DiscordClient client, ulong guildId, ulong channelId, ulong userId) { return PlatformImage.FromStream( diff --git a/Anarchy/REST/Guild/Guild/BaseGuild.cs b/Anarchy/REST/Guild/Guild/BaseGuild.cs index 9ad7ea10..9479ee4a 100644 --- a/Anarchy/REST/Guild/Guild/BaseGuild.cs +++ b/Anarchy/REST/Guild/Guild/BaseGuild.cs @@ -7,11 +7,9 @@ public class BaseGuild : MinimalGuild [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("icon")] private string _iconHash; - public DiscordCDNImage Icon { get @@ -23,14 +21,12 @@ public DiscordCDNImage Icon } } - protected void Update(BaseGuild guild) { Name = guild.Name; _iconHash = guild._iconHash; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Guild/Guild/DiscordGuild.cs b/Anarchy/REST/Guild/Guild/DiscordGuild.cs index 23413878..2605e289 100644 --- a/Anarchy/REST/Guild/Guild/DiscordGuild.cs +++ b/Anarchy/REST/Guild/Guild/DiscordGuild.cs @@ -28,7 +28,6 @@ public DiscordGuild() }; } - [JsonProperty("discovery_splash")] private string _discoverySplashHash; @@ -43,19 +42,15 @@ public DiscordCDNImage DiscoverySplash } } - [JsonProperty("max_members")] public uint MaxMembers { get; private set; } - [JsonProperty("max_video_channel_users")] public uint MaxLivestreams { get; private set; } - [JsonProperty("preferred_locale")] public DiscordLanguage? PreferredLanguage { get; private set; } - [JsonProperty("rules_channel_id")] private ulong? _rulesChannelId; @@ -70,7 +65,6 @@ public MinimalTextChannel RulesChannel } } - [JsonProperty("public_updates_channel_id")] private ulong? _updateChannelId; @@ -85,27 +79,21 @@ public MinimalTextChannel PublicUpdatesChannel } } - [JsonProperty("unavailable")] public bool Unavailable { get; internal set; } - [JsonProperty("premium_subscription_count")] public uint? NitroBoosts { get; private set; } - [JsonProperty("region")] public string Region { get; private set; } - [JsonProperty("default_message_notifications")] public GuildDefaultNotifications DefaultNotifications { get; private set; } - [JsonProperty("premium_tier")] public GuildPremiumTier PremiumTier { get; private set; } - [JsonProperty("roles")] internal ConcurrentList _roles; @@ -122,7 +110,6 @@ public DiscordRole EveryoneRole } } - [JsonProperty("emojis")] internal List _emojis; @@ -140,29 +127,23 @@ public IReadOnlyList Emojis } } - [JsonProperty("owner_id")] public ulong OwnerId { get; private set; } - [JsonProperty("mfa_level")] public bool MfaRequired { get; private set; } - [JsonProperty("system_channel_id")] private ulong? _sysChannelId; - [JsonProperty("system_channel_flags")] private int _sysChannelFlags; - public SystemChannelInformation SystemChannel { get { return new SystemChannelInformation(_sysChannelId, _sysChannelFlags).SetClient(Client); } } - internal void Update(DiscordGuild guild) { base.Update(guild); @@ -183,7 +164,6 @@ internal void Update(DiscordGuild guild) _sysChannelFlags = guild._sysChannelFlags; } - public async Task UpdateAsync() { Update(await Client.GetGuildAsync(Id)); @@ -197,7 +177,6 @@ public void Update() UpdateAsync().GetAwaiter().GetResult(); } - public new async Task ModifyAsync(GuildProperties properties) { Update(await Client.ModifyGuildAsync(Id, properties)); @@ -212,7 +191,6 @@ public void Update() ModifyAsync(properties).GetAwaiter().GetResult(); } - public override async Task> GetRolesAsync() { var roles = await base.GetRolesAsync(); @@ -229,7 +207,6 @@ public override IReadOnlyList GetRoles() return GetRolesAsync().Result; } - public override async Task> SetRolePositionsAsync(List positions) { var roles = await base.SetRolePositionsAsync(positions); @@ -243,7 +220,6 @@ public override IReadOnlyList SetRolePositions(List> GetEmojisAsync() { return _emojis = (await base.GetEmojisAsync()).ToList(); @@ -257,7 +233,6 @@ public override IReadOnlyList GetEmojis() return GetEmojisAsync().Result; } - public new void Dispose() { base.Dispose(); diff --git a/Anarchy/REST/Guild/Guild/MinimalGuild.cs b/Anarchy/REST/Guild/Guild/MinimalGuild.cs index 87695114..62827ed3 100644 --- a/Anarchy/REST/Guild/Guild/MinimalGuild.cs +++ b/Anarchy/REST/Guild/Guild/MinimalGuild.cs @@ -17,7 +17,6 @@ public MinimalGuild(ulong guildId) Id = guildId; } - public async Task ModifyAsync(GuildProperties properties) { await Client.ModifyGuildAsync(Id, properties); @@ -32,7 +31,6 @@ public void Modify(GuildProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task DeleteAsync() { await Client.DeleteGuildAsync(Id); @@ -46,7 +44,6 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public async Task LeaveAsync(bool lurking = false) { await Client.LeaveGuildAsync(Id, lurking); @@ -60,7 +57,6 @@ public void Leave(bool lurking = false) LeaveAsync(lurking).GetAwaiter().GetResult(); } - public async Task SetNicknameAsync(string nickname) { await Client.SetClientNicknameAsync(Id, nickname); @@ -71,7 +67,6 @@ public void SetNickname(string nickname) SetNicknameAsync(nickname).GetAwaiter().GetResult(); } - public async Task AcknowledgeMessagesAsync() { await Client.AcknowledgeGuildMessagesAsync(Id); @@ -85,7 +80,6 @@ public void AcknowledgeMessages() AcknowledgeMessagesAsync().GetAwaiter().GetResult(); } - public async Task ModifyClientSettingsAsync(GuildSettingsProperties properties) { return await Client.ModifyGuildSettingsAsync(Id, properties); @@ -96,7 +90,6 @@ public ClientGuildSettings ModifyClientSettings(GuildSettingsProperties properti return ModifyClientSettingsAsync(properties).GetAwaiter().GetResult(); } - public async Task> GetTemplatesAsync() { return await Client.GetGuildTemplatesAsync(Id); @@ -110,7 +103,6 @@ public IReadOnlyList GetTemplates() return GetTemplatesAsync().GetAwaiter().GetResult(); } - public async Task CreateTemplateAsync(string name, string description) { return await Client.CreateGuildTemplateAsync(Id, name, description); @@ -124,7 +116,6 @@ public DiscordGuildTemplate CreateTemplate(string name, string description) return CreateTemplateAsync(name, description).GetAwaiter().GetResult(); } - public async Task DeleteTemplateAsync(string templateCode) { return await Client.DeleteGuildTemplateAsync(Id, templateCode); @@ -135,7 +126,6 @@ public DiscordGuildTemplate DeleteTemplate(string templateCode) return DeleteTemplateAsync(templateCode).GetAwaiter().GetResult(); } - public async Task SetVanityUrlAsync(string vanityCode) { await Client.SetGuildVanityUrlAsync(Id, vanityCode); @@ -146,7 +136,6 @@ public void SetVanityUrl(string vanityCode) SetVanityUrlAsync(vanityCode).GetAwaiter().GetResult(); } - public Task GetWelcomeScreenAsync() { return Client.GetWelcomeScreenAsync(Id); @@ -157,7 +146,6 @@ public WelcomeScreen GetWelcomeScreen() return GetWelcomeScreenAsync().GetAwaiter().GetResult(); } - public Task ModifyWelcomeScreenAsync(WelcomeScreenProperties properties) { return Client.ModifyWelcomeScreenAsync(Id, properties); @@ -168,14 +156,12 @@ public WelcomeScreen ModifyWelcomeScreen(WelcomeScreenProperties properties) return ModifyWelcomeScreenAsync(properties).GetAwaiter().GetResult(); } - public Task GetVerificationFormAsync(string inviteCode) => Client.GetGuildVerificationFormAsync(Id, inviteCode); public GuildVerificationForm GetVerificationForm(string inviteCode) => GetVerificationFormAsync(inviteCode).GetAwaiter().GetResult(); public Task ModifyVerificationFormAsync(VerificationFormProperties properties) => Client.ModifyGuildVerificationFormAsync(Id, properties); public GuildVerificationForm ModifyVerificationForm(VerificationFormProperties properties) => ModifyVerificationFormAsync(properties).GetAwaiter().GetResult(); - public virtual async Task> GetChannelsAsync() { return await Client.GetGuildChannelsAsync(Id); @@ -189,7 +175,6 @@ public virtual IReadOnlyList GetChannels() return GetChannelsAsync().GetAwaiter().GetResult(); } - public async Task CreateChannelAsync(string name, ChannelType type, ulong? parentId = null) { return await Client.CreateGuildChannelAsync(Id, name, type, parentId); @@ -205,7 +190,6 @@ public GuildChannel CreateChannel(string name, ChannelType type, ulong? parentId return CreateChannelAsync(name, type, parentId).GetAwaiter().GetResult(); } - public virtual async Task> GetEmojisAsync() { return await Client.GetGuildEmojisAsync(Id); @@ -219,7 +203,6 @@ public virtual IReadOnlyList GetEmojis() return GetEmojisAsync().GetAwaiter().GetResult(); } - public async Task GetEmojiAsync(ulong emojiId) { return await Client.GetGuildEmojiAsync(Id, emojiId); @@ -234,7 +217,6 @@ public DiscordEmoji GetEmoji(ulong emojiId) return GetEmojiAsync(emojiId).GetAwaiter().GetResult(); } - public async Task CreateEmojiAsync(EmojiProperties properties) { return await Client.CreateEmojiAsync(Id, properties); @@ -249,7 +231,6 @@ public DiscordEmoji CreateEmoji(EmojiProperties properties) return CreateEmojiAsync(properties).GetAwaiter().GetResult(); } - public virtual async Task> GetRolesAsync() { return await Client.GetGuildRolesAsync(Id); @@ -263,7 +244,6 @@ public virtual IReadOnlyList GetRoles() return GetRolesAsync().GetAwaiter().GetResult(); } - public async Task CreateRoleAsync(RoleProperties properties = null) { return await Client.CreateRoleAsync(Id, properties); @@ -279,7 +259,6 @@ public DiscordRole CreateRole(RoleProperties properties = null) return CreateRoleAsync(properties).GetAwaiter().GetResult(); } - public virtual async Task> SetRolePositionsAsync(List roles) { return await Client.SetRolePositionsAsync(Id, roles); @@ -290,7 +269,6 @@ public virtual IReadOnlyList SetRolePositions(List> GetInvitesAsync() { return await Client.GetGuildInvitesAsync(Id); @@ -301,7 +279,6 @@ public IReadOnlyList GetInvites() return GetInvitesAsync().GetAwaiter().GetResult(); } - public async Task> GetWebhooksAsync() { return await Client.GetGuildWebhooksAsync(Id); @@ -312,7 +289,6 @@ public IReadOnlyList GetWebhooks() return GetWebhooksAsync().GetAwaiter().GetResult(); } - public async Task> GetAuditLogAsync(AuditLogFilters filters = null) { return await Client.GetAuditLogAsync(Id, filters); @@ -327,7 +303,6 @@ public IReadOnlyList GetAuditLog(AuditLogFilters filters = null) return GetAuditLogAsync(filters).GetAwaiter().GetResult(); } - public async Task GetMemberAsync(ulong userId) { return await Client.GetGuildMemberAsync(Id, userId); @@ -343,7 +318,6 @@ public GuildMember GetMember(ulong userId) return GetMemberAsync(userId).GetAwaiter().GetResult(); } - public async Task> GetBansAsync() { return await Client.GetGuildBansAsync(Id); @@ -357,7 +331,6 @@ public IReadOnlyList GetBans() return GetBansAsync().GetAwaiter().GetResult(); } - public async Task GetBanAsync(ulong userId) { return await Client.GetGuildBanAsync(Id, userId); @@ -372,7 +345,6 @@ public DiscordBan GetBan(ulong userId) return GetBanAsync(userId).GetAwaiter().GetResult(); } - public async Task BanMemberAsync(ulong userId, string reason = null, uint deleteMessageDays = 0) { await Client.BanGuildMemberAsync(Id, userId, reason, deleteMessageDays); @@ -383,7 +355,6 @@ public void BanMember(ulong userId, string reason = null, uint deleteMessageDays BanMemberAsync(userId, reason, deleteMessageDays).GetAwaiter().GetResult(); } - public static implicit operator ulong(MinimalGuild instance) { return instance.Id; diff --git a/Anarchy/REST/Guild/Guild/PartialGuild.cs b/Anarchy/REST/Guild/Guild/PartialGuild.cs index 9c78e07c..c04ebf8b 100644 --- a/Anarchy/REST/Guild/Guild/PartialGuild.cs +++ b/Anarchy/REST/Guild/Guild/PartialGuild.cs @@ -9,15 +9,12 @@ public class PartialGuild : BaseGuild [JsonProperty("owner")] public bool Owner { get; private set; } - [JsonProperty("permissions")] public DiscordPermission Permissions { get; private set; } - [JsonProperty("features")] public IReadOnlyList Features { get; private set; } - public async Task GetGuildAsync() { return await Client.GetGuildAsync(Id); diff --git a/Anarchy/REST/Guild/Member/Extensions.cs b/Anarchy/REST/Guild/Member/Extensions.cs index 4c887f8b..1c806d8f 100644 --- a/Anarchy/REST/Guild/Member/Extensions.cs +++ b/Anarchy/REST/Guild/Member/Extensions.cs @@ -23,7 +23,6 @@ public static GuildMember GetGuildMember(this DiscordClient client, ulong guildI return client.GetGuildMemberAsync(guildId, userId).GetAwaiter().GetResult(); } - public static async Task ModifyGuildMemberAsync(this DiscordClient client, ulong guildId, ulong userId, GuildMemberProperties properties) { await client.HttpClient.PatchAsync($"/guilds/{guildId}/members/{userId}", properties); @@ -34,7 +33,6 @@ public static void ModifyGuildMember(this DiscordClient client, ulong guildId, u client.ModifyGuildMemberAsync(guildId, userId, properties).GetAwaiter().GetResult(); } - public static async Task SetClientNicknameAsync(this DiscordClient client, ulong guildId, string nickname) { await client.HttpClient.PatchAsync($"/guilds/{guildId}/members/@me/nick", $"{{\"nick\":\"{nickname}\"}}"); @@ -45,7 +43,6 @@ public static void SetClientNickname(this DiscordClient client, ulong guildId, s client.SetClientNicknameAsync(guildId, nickname).GetAwaiter().GetResult(); } - public static async Task KickGuildMemberAsync(this DiscordClient client, ulong guildId, ulong userId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/members/{userId}"); @@ -61,7 +58,6 @@ public static void KickGuildMember(this DiscordClient client, ulong guildId, ulo client.KickGuildMemberAsync(guildId, userId).GetAwaiter().GetResult(); } - public static async Task GetGuildPrunableMembersAsync(this DiscordClient client, ulong guildId, MemberPruneProperties properties) { string url = $"/guilds/{guildId}/prune?days={properties.Days}"; @@ -77,7 +73,6 @@ public static uint GetGuildPrunableMembers(this DiscordClient client, ulong guil return client.GetGuildPrunableMembersAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task PruneGuildMembersAsync(this DiscordClient client, ulong guildId, MemberPruneProperties properties) { return (await client.HttpClient.PostAsync($"/guilds/{guildId}/prune", properties)) @@ -89,7 +84,6 @@ public static uint PruneGuildMembers(this DiscordClient client, ulong guildId, M return client.PruneGuildMembersAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task BanGuildMemberAsync(this DiscordClient client, ulong guildId, ulong userId, string reason = null, uint deleteMessageDays = 0) { await client.HttpClient.PutAsync($"/guilds/{guildId}/bans/{userId}?delete-message-days={deleteMessageDays}&reason={reason}"); diff --git a/Anarchy/REST/Guild/Member/Models/DiscordBan.cs b/Anarchy/REST/Guild/Member/Models/DiscordBan.cs index 51adbb0f..63f34292 100644 --- a/Anarchy/REST/Guild/Member/Models/DiscordBan.cs +++ b/Anarchy/REST/Guild/Member/Models/DiscordBan.cs @@ -9,15 +9,12 @@ public DiscordBan() OnClientUpdated += (sender, e) => User.SetClient(Client); } - [JsonProperty("reason")] public string Reason { get; private set; } - [JsonProperty("user")] public DiscordUser User { get; private set; } - internal ulong GuildId { get; set; } public MinimalGuild Guild @@ -28,7 +25,6 @@ public MinimalGuild Guild } } - /// /// Unbans the user /// @@ -37,7 +33,6 @@ public void Unban() Client.UnbanGuildMember(GuildId, User.Id); } - public override string ToString() { return User.ToString(); diff --git a/Anarchy/REST/Guild/Member/Models/GuildMember.cs b/Anarchy/REST/Guild/Member/Models/GuildMember.cs index a47aa13c..69a7086a 100644 --- a/Anarchy/REST/Guild/Member/Models/GuildMember.cs +++ b/Anarchy/REST/Guild/Member/Models/GuildMember.cs @@ -13,19 +13,15 @@ public class GuildMember : PartialGuildMember, IDisposable, IMentionable [JsonProperty("nick")] public string Nickname { get; private set; } - [JsonProperty("roles")] public IReadOnlyList Roles { get; private set; } - [JsonProperty("joined_at")] public DateTime JoinedAt { get; internal set; } - [JsonProperty("premium_since")] public DateTime? BoostingSince { get; private set; } - /// /// Updates the member's information /// @@ -42,7 +38,6 @@ public async Task UpdateAsync() Update(await Client.GetGuildMemberAsync(GuildId, User.Id)); } - public async Task ModifyAsync(GuildMemberProperties properties) { await Client.ModifyGuildMemberAsync(GuildId, User.Id, properties); @@ -63,7 +58,6 @@ public void Modify(GuildMemberProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task AddRoleAsync(ulong roleId) { await Client.AddRoleToUserAsync(GuildId, roleId, User.Id); @@ -78,7 +72,6 @@ public void AddRole(ulong roleId) AddRoleAsync(roleId).GetAwaiter().GetResult(); } - public async Task RemoveRoleAsync(ulong roleId) { await Client.RemoveRoleFromUserAsync(GuildId, roleId, User.Id); @@ -93,12 +86,11 @@ public void RemoveRole(ulong roleId) RemoveRoleAsync(roleId).GetAwaiter().GetResult(); } - private async Task SeekGuildAsync() { if (Client.GetType() == typeof(DiscordSocketClient)) { - var socketClient = (DiscordSocketClient)Client; + var socketClient = (DiscordSocketClient) Client; if (socketClient.Config.Cache) return socketClient.GetCachedGuild(GuildId); @@ -139,8 +131,6 @@ public DiscordPermission GetPermissions() return GetPermissionsAsync().GetAwaiter().GetResult(); } - - public async Task GetPermissionsAsync(IEnumerable affectedBy) { var guild = await SeekGuildAsync(); @@ -164,7 +154,6 @@ public DiscordPermission GetPermissions(IEnumerable return GetPermissionsAsync(affectedBy).GetAwaiter().GetResult(); } - public async Task KickAsync() { await Client.KickGuildMemberAsync(GuildId, User.Id); @@ -178,7 +167,6 @@ public void Kick() KickAsync().GetAwaiter().GetResult(); } - public async Task BanAsync(string reason = null, uint deleteMessageDays = 0) { await Client.BanGuildMemberAsync(GuildId, User.Id, reason, deleteMessageDays); @@ -194,7 +182,6 @@ public void Ban(string reason = null, uint deleteMessageDays = 0) BanAsync(reason, deleteMessageDays).GetAwaiter().GetResult(); } - public async Task UnbanAsync() { await Client.UnbanGuildMemberAsync(GuildId, User.Id); @@ -208,25 +195,21 @@ public void Unban() UnbanAsync().GetAwaiter().GetResult(); } - public string AsMessagable() { return User.AsMessagable(); } - public override string ToString() { return User.ToString(); } - public static implicit operator ulong(GuildMember instance) { return instance.User.Id; } - public new void Dispose() { Nickname = null; diff --git a/Anarchy/REST/Guild/Member/Models/GuildMemberProperties.cs b/Anarchy/REST/Guild/Member/Models/GuildMemberProperties.cs index 0e6215f7..fa154794 100644 --- a/Anarchy/REST/Guild/Member/Models/GuildMemberProperties.cs +++ b/Anarchy/REST/Guild/Member/Models/GuildMemberProperties.cs @@ -6,7 +6,6 @@ namespace Discord public class GuildMemberProperties { - internal readonly DiscordParameter NickProperty = new DiscordParameter(); [JsonProperty("nick")] public string Nickname @@ -15,13 +14,11 @@ public string Nickname set { NickProperty.Value = value; } } - public bool ShouldSerializeNickname() { return NickProperty.Set; } - internal readonly DiscordParameter> RoleProperty = new DiscordParameter>(); [JsonProperty("roles")] public List Roles @@ -30,13 +27,11 @@ public List Roles set { RoleProperty.Value = value; } } - public bool ShouldSerializeRoles() { return RoleProperty.Set; } - private readonly DiscordParameter ChannelProperty = new DiscordParameter(); [JsonProperty("channel_id")] public ulong ChannelId @@ -45,7 +40,6 @@ public ulong ChannelId set { ChannelProperty.Value = value; } } - private readonly DiscordParameter MuteProperty = new DiscordParameter(); [JsonProperty("mute")] public bool Muted @@ -54,13 +48,11 @@ public bool Muted set { MuteProperty.Value = value; } } - public bool ShouldSerializeMuted() { return MuteProperty.Set; } - private readonly DiscordParameter DeafProperty = new DiscordParameter(); [JsonProperty("deaf")] public bool Deafened @@ -69,7 +61,6 @@ public bool Deafened set { DeafProperty.Value = value; } } - public bool ShouldSerializeDeafened() { return DeafProperty.Set; diff --git a/Anarchy/REST/Guild/Member/Models/MemberPruneProperties.cs b/Anarchy/REST/Guild/Member/Models/MemberPruneProperties.cs index 37a0adc1..38593ad4 100644 --- a/Anarchy/REST/Guild/Member/Models/MemberPruneProperties.cs +++ b/Anarchy/REST/Guild/Member/Models/MemberPruneProperties.cs @@ -12,17 +12,14 @@ public MemberPruneProperties() _computePrunes = true; } - [JsonProperty("compute_prune_count")] #pragma warning disable IDE0052 private readonly bool _computePrunes; #pragma warning restore - [JsonProperty("days")] public uint Days { get; set; } - [JsonProperty("include_roles")] public List IncludedRoles { get; set; } } diff --git a/Anarchy/REST/Guild/Member/Models/PartialGuildMember.cs b/Anarchy/REST/Guild/Member/Models/PartialGuildMember.cs index 2d1d8647..4c9b45f1 100644 --- a/Anarchy/REST/Guild/Member/Models/PartialGuildMember.cs +++ b/Anarchy/REST/Guild/Member/Models/PartialGuildMember.cs @@ -10,11 +10,9 @@ public PartialGuildMember() OnClientUpdated += (sender, e) => User.SetClient(Client); } - [JsonProperty("guild_id")] internal ulong GuildId { get; set; } - public MinimalGuild Guild { get @@ -23,11 +21,9 @@ public MinimalGuild Guild } } - [JsonProperty("user")] public DiscordUser User { get; internal set; } - public new void Dispose() { User = null; diff --git a/Anarchy/REST/Guild/Permissions/DiscordPermissionOverwrite.cs b/Anarchy/REST/Guild/Permissions/DiscordPermissionOverwrite.cs index 855c9514..f34bbd3e 100644 --- a/Anarchy/REST/Guild/Permissions/DiscordPermissionOverwrite.cs +++ b/Anarchy/REST/Guild/Permissions/DiscordPermissionOverwrite.cs @@ -7,19 +7,15 @@ public class DiscordPermissionOverwrite [JsonProperty("id")] public ulong AffectedId { get; internal set; } - [JsonProperty("type")] public PermissionOverwriteType Type { get; internal set; } - [JsonProperty("allow")] public DiscordPermission Allow { get; internal set; } - [JsonProperty("deny")] public DiscordPermission Deny { get; internal set; } - public OverwrittenPermissionState GetPermissionState(DiscordPermission permission) { if (Allow.HasFlag(permission)) diff --git a/Anarchy/REST/Guild/Properties/CreationProperties.cs b/Anarchy/REST/Guild/Properties/CreationProperties.cs index 90ebb2fe..0ceed381 100644 --- a/Anarchy/REST/Guild/Properties/CreationProperties.cs +++ b/Anarchy/REST/Guild/Properties/CreationProperties.cs @@ -10,11 +10,9 @@ internal class GuildCreationProperties [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("region")] public string Region { get; set; } - [JsonProperty("icon")] public DiscordImage Icon { get; set; } } diff --git a/Anarchy/REST/Guild/Properties/GuildProperties.cs b/Anarchy/REST/Guild/Properties/GuildProperties.cs index 2cbec4c7..7f676c9d 100644 --- a/Anarchy/REST/Guild/Properties/GuildProperties.cs +++ b/Anarchy/REST/Guild/Properties/GuildProperties.cs @@ -16,13 +16,11 @@ public string Name set { NameProperty.Value = value; } } - public bool ShouldSerializeName() { return NameProperty.Set; } - private readonly DiscordParameter RegionProperty = new DiscordParameter(); [JsonProperty("region")] public string Region @@ -31,13 +29,11 @@ public string Region set { RegionProperty.Value = value; } } - public bool ShouldSerializeRegion() { return RegionProperty.Set; } - internal readonly DiscordParameter IconProperty = new DiscordParameter(); [JsonProperty("icon")] public DiscordImage Icon @@ -46,13 +42,11 @@ public DiscordImage Icon set { IconProperty.Value = value; } } - public bool ShouldSerializeIcon() { return IconProperty.Set; } - private readonly DiscordParameter OwnerProperty = new DiscordParameter(); [JsonProperty("owner_id")] public ulong OwnerId @@ -61,13 +55,11 @@ public ulong OwnerId set { OwnerProperty.Value = value; } } - public bool ShouldSerializeOwnerId() { return OwnerProperty.Set; } - private readonly DiscordParameter VerificationProperty = new DiscordParameter(); [JsonProperty("verification_level")] public GuildVerificationLevel VerificationLevel @@ -76,13 +68,11 @@ public GuildVerificationLevel VerificationLevel set { VerificationProperty.Value = value; } } - public bool ShouldSerializeVerificationLevel() { return VerificationProperty.Set; } - private readonly DiscordParameter NotificationsProperty = new DiscordParameter(); [JsonProperty("default_message_notifications")] public GuildDefaultNotifications DefaultNotifications @@ -91,13 +81,11 @@ public GuildDefaultNotifications DefaultNotifications set { NotificationsProperty.Value = value; } } - public bool ShouldSerializeDefaultNotifications() { return NotificationsProperty.Set; } - private readonly DiscordParameter> FeatureProperty = new DiscordParameter>(); [JsonProperty("features")] public List Features @@ -111,7 +99,6 @@ public bool ShouldSerializeFeatures() return FeatureProperty.Set; } - private readonly DiscordParameter _updatesChannel = new DiscordParameter(); [JsonProperty("public_updates_channel_id")] public ulong? PublicUpdatesChannelId @@ -125,7 +112,6 @@ public bool ShouldSerializePublicUpdatesChannelId() return _updatesChannel.Set; } - private readonly DiscordParameter _rulesChannel = new DiscordParameter(); [JsonProperty("rules_channel_id")] public ulong? RulesChannelId @@ -139,7 +125,6 @@ public bool ShouldSerializeRulesChannelId() return _rulesChannel.Set; } - private readonly DiscordParameter _preferredLocale = new DiscordParameter(); [JsonProperty("preferred_locale")] public DiscordLanguage? PreferredLanguage @@ -153,7 +138,6 @@ public bool ShouldSerializePreferredLanguage() return _preferredLocale.Set; } - internal readonly DiscordParameter VanityProperty = new DiscordParameter(); public string VanityUrlCode { @@ -161,7 +145,6 @@ public string VanityUrlCode set { VanityProperty.Value = value; } } - private readonly DiscordParameter _contentFilterParam = new DiscordParameter(); [JsonProperty("explicit_content_filter")] public ExplicitContentFilter ExplicitContentFilter @@ -172,7 +155,6 @@ public ExplicitContentFilter ExplicitContentFilter public bool ShouldSerializeExplicitContentFilter() => _contentFilterParam.Set; - private readonly DiscordParameter _descParam = new DiscordParameter(); [JsonProperty("description")] public string Description diff --git a/Anarchy/REST/Guild/Role/Extensions.cs b/Anarchy/REST/Guild/Role/Extensions.cs index 646d1642..24a3bdd0 100644 --- a/Anarchy/REST/Guild/Role/Extensions.cs +++ b/Anarchy/REST/Guild/Role/Extensions.cs @@ -27,7 +27,6 @@ public static DiscordRole CreateRole(this DiscordClient client, ulong guildId, R return client.CreateRoleAsync(guildId, properties).GetAwaiter().GetResult(); } - public static async Task ModifyRoleAsync(this DiscordClient client, ulong guildId, ulong roleId, RoleProperties properties) { DiscordRole changed = (await client.HttpClient.PatchAsync($"/guilds/{guildId}/roles/{roleId}", properties)).Deserialize().SetClient(client); @@ -47,7 +46,6 @@ public static DiscordRole ModifyRole(this DiscordClient client, ulong guildId, u return client.ModifyRoleAsync(guildId, roleId, properties).GetAwaiter().GetResult(); } - public static async Task DeleteRoleAsync(this DiscordClient client, ulong guildId, ulong roleId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/roles/{roleId}"); @@ -63,7 +61,6 @@ public static void DeleteRole(this DiscordClient client, ulong guildId, ulong ro client.DeleteRoleAsync(guildId, roleId).GetAwaiter().GetResult(); } - public static async Task> SetRolePositionsAsync(this DiscordClient client, ulong guildId, List roles) { var result = (await client.HttpClient.PatchAsync($"/guilds/{guildId}/roles", roles)) @@ -79,7 +76,6 @@ public static IReadOnlyList SetRolePositions(this DiscordClient cli } #endregion - public static async Task AddRoleToUserAsync(this DiscordClient client, ulong guildId, ulong roleId, ulong userId) { await client.HttpClient.PutAsync($"/guilds/{guildId}/members/{userId}/roles/{roleId}"); @@ -96,7 +92,6 @@ public static void AddRoleToUser(this DiscordClient client, ulong guildId, ulong client.AddRoleToUserAsync(guildId, roleId, userId).GetAwaiter().GetResult(); } - public static async Task RemoveRoleFromUserAsync(this DiscordClient client, ulong guildId, ulong roleId, ulong userId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/members/{userId}/roles/{roleId}"); @@ -113,7 +108,6 @@ public static void RemoveRoleFromUser(this DiscordClient client, ulong guildId, client.RemoveRoleFromUserAsync(guildId, roleId, userId).GetAwaiter().GetResult(); } - public static async Task> GetGuildRolesAsync(this DiscordClient client, ulong guildId) { IReadOnlyList roles = (await client.HttpClient.GetAsync($"/guilds/{guildId}/roles")) diff --git a/Anarchy/REST/Guild/Role/Models/DiscordRole.cs b/Anarchy/REST/Guild/Role/Models/DiscordRole.cs index 7c34cf8f..2bb551d9 100644 --- a/Anarchy/REST/Guild/Role/Models/DiscordRole.cs +++ b/Anarchy/REST/Guild/Role/Models/DiscordRole.cs @@ -10,7 +10,6 @@ public class DiscordRole : Controllable, IMentionable [JsonProperty("id")] public ulong Id { get; private set; } - internal ulong GuildId { get; set; } public MinimalGuild Guild @@ -18,36 +17,29 @@ public MinimalGuild Guild get { return new MinimalGuild(GuildId).SetClient(Client); } } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("color")] private uint _color; public Color Color { - get { return Color.FromArgb((int)_color); } - private set { _color = (uint)Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } + get { return Color.FromArgb((int) _color); } + private set { _color = (uint) Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } } - [JsonProperty("position")] public int Position { get; private set; } - [JsonProperty("hoist")] public bool Seperated { get; private set; } - [JsonProperty("mentionable")] public bool Mentionable { get; private set; } - [JsonProperty("permissions")] public DiscordPermission Permissions { get; private set; } - public async Task ModifyAsync(RoleProperties properties) { return await Client.ModifyRoleAsync(GuildId, Id, properties); @@ -62,7 +54,6 @@ public DiscordRole Modify(RoleProperties properties) return ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task DeleteAsync() { await Client.DeleteRoleAsync(GuildId, Id); @@ -76,19 +67,16 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public string AsMessagable() { return $"<@&{Id}>"; } - public override string ToString() { return Name; } - public static implicit operator ulong(DiscordRole instance) { return instance.Id; diff --git a/Anarchy/REST/Guild/Role/Models/MinimalRole.cs b/Anarchy/REST/Guild/Role/Models/MinimalRole.cs index 1ed2a0f0..ed9a48e3 100644 --- a/Anarchy/REST/Guild/Role/Models/MinimalRole.cs +++ b/Anarchy/REST/Guild/Role/Models/MinimalRole.cs @@ -17,14 +17,12 @@ public MinimalGuild Guild public MinimalRole() { } - public MinimalRole(ulong guildId, ulong roleId) { GuildId = guildId; Id = roleId; } - /// /// Modifies the role /// @@ -34,7 +32,6 @@ public DiscordRole Modify(RoleProperties properties) return Client.ModifyRole(GuildId, Id, properties); } - /// /// Deletes the role /// @@ -43,7 +40,6 @@ public void Delete() Client.DeleteRole(GuildId, Id); } - public string AsMessagable() { return $"<@&{Id}>"; diff --git a/Anarchy/REST/Guild/Role/Models/RolePositionUpdate.cs b/Anarchy/REST/Guild/Role/Models/RolePositionUpdate.cs index b512ab76..0b297cbd 100644 --- a/Anarchy/REST/Guild/Role/Models/RolePositionUpdate.cs +++ b/Anarchy/REST/Guild/Role/Models/RolePositionUpdate.cs @@ -7,7 +7,6 @@ public class RolePositionUpdate [JsonProperty("id")] public ulong Id { get; set; } - [JsonProperty("position")] public int Position { get; set; } } diff --git a/Anarchy/REST/Guild/Role/Models/RoleProperties.cs b/Anarchy/REST/Guild/Role/Models/RoleProperties.cs index 2f810aa8..c893b8a2 100644 --- a/Anarchy/REST/Guild/Role/Models/RoleProperties.cs +++ b/Anarchy/REST/Guild/Role/Models/RoleProperties.cs @@ -16,13 +16,11 @@ public string Name set { NameProperty.Value = value; } } - public bool ShouldSerializeName() { return NameProperty.Set; } - private readonly DiscordParameter PermissionsProperty = new DiscordParameter(); [JsonProperty("permissions")] public DiscordPermission Permissions @@ -31,13 +29,11 @@ public DiscordPermission Permissions set { PermissionsProperty.Value = value; } } - public bool ShouldSerialize_permissions() { return PermissionsProperty.Set; } - private readonly DiscordParameter ColorProperty = new DiscordParameter(); [JsonProperty("color")] #pragma warning disable IDE1006, IDE0051 @@ -49,17 +45,15 @@ private uint _color #pragma warning restore IDE1006, IDE0051 public Color Color { - get { return Color.FromArgb((int)_color); } - set { _color = (uint)Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } + get { return Color.FromArgb((int) _color); } + set { _color = (uint) Color.FromArgb(0, value.R, value.G, value.B).ToArgb(); } } - public bool ShouldSerialize_color() { return ColorProperty.Set; } - private readonly DiscordParameter SeperatedProperty = new DiscordParameter(); [JsonProperty("hoist")] public bool Seperated @@ -68,13 +62,11 @@ public bool Seperated set { SeperatedProperty.Value = value; } } - public bool ShouldSerializeSeperated() { return SeperatedProperty.Set; } - private readonly DiscordParameter MentionableProperty = new DiscordParameter(); [JsonProperty("mentionable")] public bool Mentionable @@ -83,13 +75,11 @@ public bool Mentionable set { MentionableProperty.Value = value; } } - public bool ShouldSerializeMentionable() { return MentionableProperty.Set; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Guild/Settings/ChannelSettingsProperties.cs b/Anarchy/REST/Guild/Settings/ChannelSettingsProperties.cs index 2385a848..d0b143ef 100644 --- a/Anarchy/REST/Guild/Settings/ChannelSettingsProperties.cs +++ b/Anarchy/REST/Guild/Settings/ChannelSettingsProperties.cs @@ -14,13 +14,11 @@ public class ChannelSettingsProperties }; #pragma warning restore - public bool ShouldSerialize_muteConfig() { return Muted; } - private readonly DiscordParameter _mutedProperty = new DiscordParameter(); [JsonProperty("muted")] public bool Muted @@ -29,13 +27,11 @@ public bool Muted set { _mutedProperty.Value = value; } } - public bool ShouldSerializeMuted() { return _mutedProperty.Set; } - private readonly DiscordParameter _notifsProperty = new DiscordParameter(); [JsonProperty("message_notifications")] public ClientNotificationLevel Notifications @@ -44,7 +40,6 @@ public ClientNotificationLevel Notifications set { _notifsProperty.Value = value; } } - public bool ShouldSerializeNotifications() { return _notifsProperty.Set; diff --git a/Anarchy/REST/Guild/Settings/ClientGuildSettings.cs b/Anarchy/REST/Guild/Settings/ClientGuildSettings.cs index f3309d10..c383eef8 100644 --- a/Anarchy/REST/Guild/Settings/ClientGuildSettings.cs +++ b/Anarchy/REST/Guild/Settings/ClientGuildSettings.cs @@ -16,27 +16,21 @@ public MinimalGuild Guild } } - [JsonProperty("muted")] public bool Muted { get; private set; } - [JsonProperty("message_notifications")] public ClientNotificationLevel Notifications { get; private set; } - [JsonProperty("supress_everyone")] public bool SupressEveryone { get; private set; } - [JsonProperty("supress_roles")] public bool SupressRoles { get; private set; } - [JsonProperty("mobile_push")] public bool MobilePushNotifications { get; private set; } - [JsonProperty("channel_overrides")] public IReadOnlyList ChannelOverrides { get; private set; } } diff --git a/Anarchy/REST/Guild/Settings/DiscordChannelSettings.cs b/Anarchy/REST/Guild/Settings/DiscordChannelSettings.cs index 56d30931..3f54bc0a 100644 --- a/Anarchy/REST/Guild/Settings/DiscordChannelSettings.cs +++ b/Anarchy/REST/Guild/Settings/DiscordChannelSettings.cs @@ -7,11 +7,9 @@ public class DiscordChannelSettings [JsonProperty("channel_id")] public ulong Id { get; private set; } - [JsonProperty("muted")] public bool Muted { get; private set; } - [JsonProperty("message_notifications")] public ClientNotificationLevel Notifications { get; private set; } } diff --git a/Anarchy/REST/Guild/Settings/GuildMuteConfig.cs b/Anarchy/REST/Guild/Settings/GuildMuteConfig.cs index bebb3900..e0dac730 100644 --- a/Anarchy/REST/Guild/Settings/GuildMuteConfig.cs +++ b/Anarchy/REST/Guild/Settings/GuildMuteConfig.cs @@ -7,7 +7,6 @@ public class GuildMuteConfig [JsonProperty("end_time")] public int? EndTime { get; set; } - [JsonProperty("selected_time_window")] public int SelectedTimeWindow { get; set; } } diff --git a/Anarchy/REST/Guild/Settings/GuildSettingsProperties.cs b/Anarchy/REST/Guild/Settings/GuildSettingsProperties.cs index a3245a31..1971d2a6 100644 --- a/Anarchy/REST/Guild/Settings/GuildSettingsProperties.cs +++ b/Anarchy/REST/Guild/Settings/GuildSettingsProperties.cs @@ -13,13 +13,11 @@ public bool SupressEveryone set { _supressProperty.Value = value; } } - public bool ShouldSerializeSupressEveryone() { return _supressProperty.Set; } - private readonly DiscordParameter _supressRolesProperty = new DiscordParameter(); [JsonProperty("supress_roles")] public bool SupressRoles @@ -28,13 +26,11 @@ public bool SupressRoles set { _supressRolesProperty.Value = value; } } - public bool ShouldSerializeSupressRoles() { return _supressRolesProperty.Set; } - private readonly DiscordParameter> _channelsProperty = new DiscordParameter>(); [JsonProperty("channel_overrides")] public Dictionary ChannelOverrides diff --git a/Anarchy/REST/Guild/Templates/DiscordGuildTemplate.cs b/Anarchy/REST/Guild/Templates/DiscordGuildTemplate.cs index 9f0a0965..b3072e6e 100644 --- a/Anarchy/REST/Guild/Templates/DiscordGuildTemplate.cs +++ b/Anarchy/REST/Guild/Templates/DiscordGuildTemplate.cs @@ -19,31 +19,24 @@ public DiscordGuildTemplate() [JsonProperty("code")] public string Code { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("usage_count")] public int Usages { get; private set; } - [JsonProperty("creator")] public DiscordUser Creator { get; private set; } - [JsonProperty("created_at")] public DateTime CreatedAt { get; private set; } - [JsonProperty("updated_at")] public DateTime UpdatedAt { get; private set; } - [JsonProperty("source_guild_id")] private ulong _guildId; @@ -52,7 +45,6 @@ public MinimalGuild SourceGuild get { return new MinimalGuild(_guildId).SetClient(Client); } } - [JsonProperty("serialized_source_guild")] private DiscordTemplateGuild _guild; @@ -70,7 +62,6 @@ private set } } - [JsonProperty("is_dirty")] private readonly bool? _dirty; @@ -79,7 +70,6 @@ public bool HasUnsyncedChanges get { return _dirty.HasValue; } } - public async Task UpdateAsync() { var template = await Client.GetGuildTemplateAsync(Code); diff --git a/Anarchy/REST/Guild/Templates/DiscordTemplateGuild.cs b/Anarchy/REST/Guild/Templates/DiscordTemplateGuild.cs index 2ab2db76..98dfb7d9 100644 --- a/Anarchy/REST/Guild/Templates/DiscordTemplateGuild.cs +++ b/Anarchy/REST/Guild/Templates/DiscordTemplateGuild.cs @@ -17,19 +17,15 @@ public DiscordTemplateGuild() [JsonProperty("region")] public string Region { get; private set; } - [JsonProperty("verification_level")] public GuildVerificationLevel VerificationLevel { get; private set; } - [JsonProperty("explicit_content_filter")] public ExplicitContentFilter ExplicitContentFilter { get; private set; } - [JsonProperty("roles")] public IReadOnlyList Roles { get; private set; } - [JsonProperty("channels")] [JsonConverter(typeof(DeepJsonConverter))] private List _channels; @@ -39,7 +35,6 @@ public IReadOnlyList Channels get { return _channels; } } - internal void SetGuildId(ulong guildId) { foreach (var role in Roles) diff --git a/Anarchy/REST/Guild/Templates/GuildTemplateExtensions.cs b/Anarchy/REST/Guild/Templates/GuildTemplateExtensions.cs index e49913e3..a05cd33a 100644 --- a/Anarchy/REST/Guild/Templates/GuildTemplateExtensions.cs +++ b/Anarchy/REST/Guild/Templates/GuildTemplateExtensions.cs @@ -22,7 +22,6 @@ public static IReadOnlyList CreateTemplatedGuild(this DiscordClien return client.CreateTemplatedGuildAsync(templateCode, name, icon).GetAwaiter().GetResult(); } - public static async Task CreateGuildTemplateAsync(this DiscordClient client, ulong guildId, string name, string description) { return (await client.HttpClient.PostAsync($"/guilds/{guildId}/templates", $"{{\"name\":\"{name}\",\"description\":\"{description}\"}}")).Deserialize().SetClient(client); @@ -36,7 +35,6 @@ public static DiscordGuildTemplate CreateGuildTemplate(this DiscordClient client return client.CreateGuildTemplateAsync(guildId, name, description).GetAwaiter().GetResult(); } - public static async Task DeleteGuildTemplateAsync(this DiscordClient client, ulong guildId, string templateCode) { return (await client.HttpClient.DeleteAsync($"/guilds/{guildId}/templates/{templateCode}")).Deserialize().SetClient(client); @@ -50,7 +48,6 @@ public static DiscordGuildTemplate DeleteGuildTemplate(this DiscordClient client return client.DeleteGuildTemplateAsync(guildId, templateCode).GetAwaiter().GetResult(); } - public static async Task> GetGuildTemplatesAsync(this DiscordClient client, ulong guildId) { return (await client.HttpClient.GetAsync($"/guilds/{guildId}/templates")).Deserialize>().SetClientsInList(client); @@ -64,7 +61,6 @@ public static IReadOnlyList GetGuildTemplates(this Discord return client.GetGuildTemplatesAsync(guildId).GetAwaiter().GetResult(); } - public static async Task GetGuildTemplateAsync(this DiscordClient client, string code) { return (await client.HttpClient.GetAsync("/guilds/templates/" + code)).Deserialize().SetClient(client); diff --git a/Anarchy/REST/Guild/Threads/DiscordThread.cs b/Anarchy/REST/Guild/Threads/DiscordThread.cs index 4f24ecf5..21aac3f4 100644 --- a/Anarchy/REST/Guild/Threads/DiscordThread.cs +++ b/Anarchy/REST/Guild/Threads/DiscordThread.cs @@ -134,7 +134,6 @@ public DiscordMessage SendMessage(EmbedMaker embed) return SendMessageAsync(embed).GetAwaiter().GetResult(); } - public async Task SendFileAsync(string fileName, byte[] fileData, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, fileName, fileData, message, tts); @@ -145,7 +144,6 @@ public DiscordMessage SendFile(string fileName, byte[] fileData, string message return SendFileAsync(fileName, fileData, message, tts).Result; } - public async Task SendFileAsync(string filePath, string message = null, bool tts = false) { return await Client.SendFileAsync(Id, filePath, message, tts); @@ -156,7 +154,6 @@ public DiscordMessage SendFile(string filePath, string message = null, bool tts return SendFileAsync(filePath, message, tts).Result; } - public async Task DeleteMessagesAsync(List messages) { await Client.DeleteMessagesAsync(Id, messages); @@ -172,7 +169,6 @@ public void DeleteMessages(List messages) DeleteMessagesAsync(messages).GetAwaiter().GetResult(); } - public async Task> GetMessagesAsync(MessageFilters filters = null) { return await Client.GetChannelMessagesAsync(Id, filters); @@ -187,7 +183,6 @@ public IReadOnlyList GetMessages(MessageFilters filters = null) return GetMessagesAsync(filters).GetAwaiter().GetResult(); } - public async Task> GetPinnedMessagesAsync() { return await Client.GetPinnedMessagesAsync(Id); @@ -201,7 +196,6 @@ public IReadOnlyList GetPinnedMessages() return GetPinnedMessagesAsync().Result; } - public async Task PinMessageAsync(ulong messageId) { await Client.PinMessageAsync(Id, messageId); @@ -216,7 +210,6 @@ public void PinMessage(ulong messageId) PinMessageAsync(messageId).GetAwaiter().GetResult(); } - public async Task UnpinMessageAsync(ulong messageId) { await Client.UnpinChannelMessageAsync(Id, messageId); diff --git a/Anarchy/REST/Guild/Threads/ThreadProperties.cs b/Anarchy/REST/Guild/Threads/ThreadProperties.cs index a980564b..781f8118 100644 --- a/Anarchy/REST/Guild/Threads/ThreadProperties.cs +++ b/Anarchy/REST/Guild/Threads/ThreadProperties.cs @@ -17,12 +17,11 @@ public TimeSpan? TTL return null; } - set { _durationParam.Value = (int)value.Value.TotalMinutes; } + set { _durationParam.Value = (int) value.Value.TotalMinutes; } } public bool ShouldSerialize_duration() => _durationParam.Set; - private readonly DiscordParameter _archiveParam = new DiscordParameter(); [JsonProperty("archived")] public bool Archived @@ -33,7 +32,6 @@ public bool Archived public bool ShouldSerializeArchived() => _archiveParam.Set; - private readonly DiscordParameter _nameParam = new DiscordParameter(); [JsonProperty("name")] public string Name diff --git a/Anarchy/REST/Guild/Webhook/Default/DiscordDefaultWebhook.cs b/Anarchy/REST/Guild/Webhook/Default/DiscordDefaultWebhook.cs index 3ec2813f..ae209c3c 100644 --- a/Anarchy/REST/Guild/Webhook/Default/DiscordDefaultWebhook.cs +++ b/Anarchy/REST/Guild/Webhook/Default/DiscordDefaultWebhook.cs @@ -14,17 +14,15 @@ public DiscordDefaultWebhook() : base() public DiscordDefaultWebhook(ulong webhookId, string token) : this() { Client = new DiscordClient(); - Update((DiscordDefaultWebhook)Client.GetWebhook(webhookId, token)); + Update((DiscordDefaultWebhook) Client.GetWebhook(webhookId, token)); } - private void Update(DiscordDefaultWebhook hook) { Token = hook.Token; base.Update(hook); } - public new async Task UpdateAsync() { Update(await Client.GetWebhookAsync(Id, Token)); @@ -38,7 +36,6 @@ private void Update(DiscordDefaultWebhook hook) UpdateAsync().GetAwaiter().GetResult(); } - public new async Task DeleteAsync() { await Client.DeleteWebhookAsync(Id, Token); @@ -52,7 +49,6 @@ private void Update(DiscordDefaultWebhook hook) DeleteAsync().GetAwaiter().GetResult(); } - public async Task SendMessageAsync(string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null) { await Client.SendWebhookMessageAsync(Id, Token, content, embed, profile); diff --git a/Anarchy/REST/Guild/Webhook/Default/DiscordWebhookProfile.cs b/Anarchy/REST/Guild/Webhook/Default/DiscordWebhookProfile.cs index 2161a507..aafa0352 100644 --- a/Anarchy/REST/Guild/Webhook/Default/DiscordWebhookProfile.cs +++ b/Anarchy/REST/Guild/Webhook/Default/DiscordWebhookProfile.cs @@ -9,7 +9,6 @@ public string Username set { NameProperty.Value = value; } } - internal DiscordParameter AvatarProperty = new DiscordParameter(); public string AvatarUrl { diff --git a/Anarchy/REST/Guild/Webhook/Default/WebhookMessageProperties.cs b/Anarchy/REST/Guild/Webhook/Default/WebhookMessageProperties.cs index 2da5f893..22a7567f 100644 --- a/Anarchy/REST/Guild/Webhook/Default/WebhookMessageProperties.cs +++ b/Anarchy/REST/Guild/Webhook/Default/WebhookMessageProperties.cs @@ -11,7 +11,6 @@ internal class WebhookMessageProperties [JsonProperty("content")] public string Content { get; set; } - [JsonProperty("embeds")] private List _embeds; public DiscordEmbed Embed @@ -29,7 +28,6 @@ public DiscordEmbed Embed } } - internal DiscordParameter NameProperty = new DiscordParameter(); [JsonProperty("username")] public string Username @@ -38,13 +36,11 @@ public string Username set { NameProperty.Value = value; } } - public bool ShouldSerializeUsername() { return NameProperty.Set; } - internal DiscordParameter AvatarProperty = new DiscordParameter(); [JsonProperty("avatar_url")] public string AvatarUrl @@ -53,7 +49,6 @@ public string AvatarUrl set { AvatarProperty.Value = value; } } - public bool ShouldSerializeAvatarUrl() { return AvatarProperty.Set; diff --git a/Anarchy/REST/Guild/Webhook/DiscordWebhook.cs b/Anarchy/REST/Guild/Webhook/DiscordWebhook.cs index a44cddf6..c2e90f8f 100644 --- a/Anarchy/REST/Guild/Webhook/DiscordWebhook.cs +++ b/Anarchy/REST/Guild/Webhook/DiscordWebhook.cs @@ -8,15 +8,12 @@ public class DiscordWebhook : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("type")] public DiscordWebhookType Type { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("avatar")] private string _avatarHash; @@ -31,25 +28,20 @@ public DiscordCDNImage Avatar } } - [JsonProperty("user")] public DiscordUser Creator { get; private set; } - [JsonProperty("channel_id")] public ulong ChannelId { get; private set; } - [JsonProperty("guild_id")] public ulong GuildId { get; private set; } - public DiscordWebhook() { OnClientUpdated += (s, e) => Creator.SetClient(Client); } - protected void Update(DiscordWebhook hook) { Id = hook.Id; @@ -61,7 +53,6 @@ protected void Update(DiscordWebhook hook) GuildId = hook.GuildId; } - public async Task UpdateAsync() { Update(await Client.GetWebhookAsync(Id)); @@ -89,7 +80,6 @@ public void Modify(DiscordWebhookProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task DeleteAsync() { await Client.DeleteWebhookAsync(Id); @@ -103,7 +93,6 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Guild/Webhook/DiscordWebhookProperties.cs b/Anarchy/REST/Guild/Webhook/DiscordWebhookProperties.cs index 42732cc9..a970029f 100644 --- a/Anarchy/REST/Guild/Webhook/DiscordWebhookProperties.cs +++ b/Anarchy/REST/Guild/Webhook/DiscordWebhookProperties.cs @@ -15,13 +15,11 @@ public string Name set { NameProperty.Value = value; } } - public bool ShouldSerializeName() { return NameProperty.Set; } - private readonly DiscordParameter AvatarProperty = new DiscordParameter(); [JsonProperty("avatar")] public DiscordImage Avatar @@ -30,13 +28,11 @@ public DiscordImage Avatar set { AvatarProperty.Value = value; } } - public bool ShouldSeriaizeAvatar() { return AvatarProperty.Set; } - private readonly DiscordParameter ChannelProperty = new DiscordParameter(); [JsonProperty("channel_id")] public ulong ChannelId @@ -45,13 +41,11 @@ public ulong ChannelId set { ChannelProperty.Value = value; } } - public bool ShouldSerializeChannelId() { return ChannelProperty.Set; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/Guild/Webhook/Extensions.cs b/Anarchy/REST/Guild/Webhook/Extensions.cs index ea7e20a7..327c1642 100644 --- a/Anarchy/REST/Guild/Webhook/Extensions.cs +++ b/Anarchy/REST/Guild/Webhook/Extensions.cs @@ -13,7 +13,6 @@ public static async Task CreateWebhookAsync(this DiscordC return hook; } - /// /// Creates a webhook /// @@ -25,7 +24,6 @@ public static DiscordDefaultWebhook CreateWebhook(this DiscordClient client, ulo return client.CreateWebhookAsync(channelId, properties).Result; } - public static async Task ModifyWebhookAsync(this DiscordClient client, ulong webhookId, DiscordWebhookProperties properties) { return (await client.HttpClient.PatchAsync($"/webhooks/{webhookId}", properties)).ParseDeterministic().SetClient(client); @@ -36,7 +34,6 @@ public static DiscordWebhook ModifyWebhook(this DiscordClient client, ulong webh return client.ModifyWebhookAsync(webhookId, properties).Result; } - public static async Task SendWebhookMessageAsync(this DiscordClient client, ulong webhookId, string webhookToken, string content, DiscordEmbed embed = null, DiscordWebhookProfile profile = null) { var properties = new WebhookMessageProperties() { Content = content, Embed = embed }; @@ -65,7 +62,6 @@ public static void SendWebhookMessage(this DiscordClient client, ulong webhookId client.SendWebhookMessageAsync(webhookId, webhookToken, content, embed, profile).GetAwaiter().GetResult(); } - public static async Task DeleteWebhookAsync(this DiscordClient client, ulong webhookId, string token = null) { await client.HttpClient.DeleteAsync($"/webhooks/{webhookId}/{token}"); @@ -80,7 +76,6 @@ public static void DeleteWebhook(this DiscordClient client, ulong webhookId, str client.DeleteWebhookAsync(webhookId, token).GetAwaiter().GetResult(); } - public static async Task GetWebhookAsync(this DiscordClient client, ulong webhookId, string token = null) { string url = "/webhooks/" + webhookId; @@ -101,7 +96,6 @@ public static DiscordWebhook GetWebhook(this DiscordClient client, ulong webhook return client.GetWebhookAsync(webhookId, token).GetAwaiter().GetResult(); } - public static async Task> GetGuildWebhooksAsync(this DiscordClient client, ulong guildId) { return (await client.HttpClient.GetAsync($"/guilds/{guildId}/webhooks")) @@ -117,7 +111,6 @@ public static IReadOnlyList GetGuildWebhooks(this DiscordClient return client.GetGuildWebhooksAsync(guildId).Result; } - public static async Task> GetChannelWebhooksAsync(this DiscordClient client, ulong channelId) { return (await client.HttpClient.GetAsync($"/channels/{channelId}/webhooks")) diff --git a/Anarchy/REST/Guild/Webhook/Following/DiscordCrosspostWebhook.cs b/Anarchy/REST/Guild/Webhook/Following/DiscordCrosspostWebhook.cs index 5fa8481d..00542ed6 100644 --- a/Anarchy/REST/Guild/Webhook/Following/DiscordCrosspostWebhook.cs +++ b/Anarchy/REST/Guild/Webhook/Following/DiscordCrosspostWebhook.cs @@ -17,11 +17,9 @@ public DiscordCrosspostWebhook() [JsonProperty("source_guild")] public BaseGuild SourceGuild { get; private set; } - [JsonProperty("source_channel")] public CrosspostChannel SourceChannel { get; private set; } - private void Update(DiscordCrosspostWebhook hook) { SourceGuild = hook.SourceGuild; @@ -29,7 +27,6 @@ private void Update(DiscordCrosspostWebhook hook) base.Update(hook); } - public new async Task UpdateAsync() { Update(await Client.GetWebhookAsync(Id)); @@ -43,7 +40,6 @@ private void Update(DiscordCrosspostWebhook hook) UpdateAsync().GetAwaiter().GetResult(); } - public new async Task ModifyAsync(DiscordWebhookProperties properties) { Update(await Client.ModifyWebhookAsync(Id, properties)); diff --git a/Anarchy/REST/HTTP/DiscordHttpClient.cs b/Anarchy/REST/HTTP/DiscordHttpClient.cs index 170581e0..c19f1c2a 100644 --- a/Anarchy/REST/HTTP/DiscordHttpClient.cs +++ b/Anarchy/REST/HTTP/DiscordHttpClient.cs @@ -16,13 +16,11 @@ public class DiscordHttpClient private readonly DiscordClient _discordClient; public string BaseUrl => DiscordHttpUtil.BuildBaseUrl(_discordClient.Config.ApiVersion, _discordClient.Config.SuperProperties.ReleaseChannel); - public DiscordHttpClient(DiscordClient discordClient) { _discordClient = discordClient; } - private string _anarchyVersion; private string AnarchyVersion { @@ -37,7 +35,6 @@ private string AnarchyVersion } } - /// /// Sends an HTTP request and checks for errors /// @@ -78,7 +75,7 @@ private async Task SendAsync(HttpMethod method, string endp }); var discordResponse = new DiscordHttpResponse( - (int)response.StatusCode, + (int) response.StatusCode, await response.Content.ReadAsStringAsync() ); DiscordHttpUtil.ValidateResponse(response, discordResponse.Body); @@ -178,7 +175,7 @@ private static string MakeJson(object payload) if (payload != null) { if (payload.GetType() == typeof(string)) - json = (string)payload; + json = (string) payload; else json = JsonConvert.SerializeObject(payload, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } diff --git a/Anarchy/REST/HTTP/DiscordHttpError.cs b/Anarchy/REST/HTTP/DiscordHttpError.cs index 847de474..038e9bb4 100644 --- a/Anarchy/REST/HTTP/DiscordHttpError.cs +++ b/Anarchy/REST/HTTP/DiscordHttpError.cs @@ -8,15 +8,12 @@ public class DiscordHttpError [JsonProperty("code")] public DiscordError Code { get; private set; } - [JsonProperty("errors")] public JObject Fields { get; private set; } - [JsonProperty("message")] public string Message { get; private set; } - public DiscordHttpError() { } public DiscordHttpError(DiscordError code, string message) diff --git a/Anarchy/REST/HTTP/DiscordHttpResponse.cs b/Anarchy/REST/HTTP/DiscordHttpResponse.cs index 2176423d..1efb5591 100644 --- a/Anarchy/REST/HTTP/DiscordHttpResponse.cs +++ b/Anarchy/REST/HTTP/DiscordHttpResponse.cs @@ -15,21 +15,19 @@ public DiscordHttpResponse(int statusCode, string content) Body = JToken.Parse(content); } - public T Deserialize() { return Body.ToObject(); } - public T ParseDeterministic() { - return ((JObject)Body).ParseDeterministic(); + return ((JObject) Body).ParseDeterministic(); } public List MultipleDeterministic() { - return ((JArray)Body).MultipleDeterministic(); + return ((JArray) Body).MultipleDeterministic(); } } } diff --git a/Anarchy/REST/HTTP/DiscordHttpUtil.cs b/Anarchy/REST/HTTP/DiscordHttpUtil.cs index 8d9a4d22..dba8130a 100644 --- a/Anarchy/REST/HTTP/DiscordHttpUtil.cs +++ b/Anarchy/REST/HTTP/DiscordHttpUtil.cs @@ -18,7 +18,7 @@ public static void ValidateResponse(HttpResponseMessage response) public static void ValidateResponse(HttpResponseMessage response, JToken body) { - int statusCode = (int)response.StatusCode; + int statusCode = (int) response.StatusCode; if (statusCode >= 400) { diff --git a/Anarchy/REST/HTTP/Exceptions/DiscordHttpException.cs b/Anarchy/REST/HTTP/Exceptions/DiscordHttpException.cs index 81d0d25c..b008e738 100644 --- a/Anarchy/REST/HTTP/Exceptions/DiscordHttpException.cs +++ b/Anarchy/REST/HTTP/Exceptions/DiscordHttpException.cs @@ -11,7 +11,7 @@ public class DiscordHttpException : Exception public FieldErrorDictionary InvalidFields { get; private set; } - public DiscordHttpException(DiscordHttpError error) : base($"{(int)error.Code} {error.Message}") + public DiscordHttpException(DiscordHttpError error) : base($"{(int) error.Code} {error.Message}") { Code = error.Code; ErrorMessage = error.Message; @@ -27,7 +27,7 @@ private static FieldErrorDictionary FindErrors(JObject obj) foreach (JProperty child in obj.Children()) { if (child.Name == "_errors") dict.Errors = child.Value.ToObject>(); - else dict[child.Name] = FindErrors((JObject)child.Value); + else dict[child.Name] = FindErrors((JObject) child.Value); } return dict; diff --git a/Anarchy/REST/HTTP/Exceptions/RateLimitException.cs b/Anarchy/REST/HTTP/Exceptions/RateLimitException.cs index bde5530f..5f8e12f4 100644 --- a/Anarchy/REST/HTTP/Exceptions/RateLimitException.cs +++ b/Anarchy/REST/HTTP/Exceptions/RateLimitException.cs @@ -11,7 +11,6 @@ public class RateLimitException : Exception RetryAfter = retryAfter; } - public override string ToString() { return RetryAfter.ToString(); diff --git a/Anarchy/REST/Interactions/InteractionResponseProperties.cs b/Anarchy/REST/Interactions/InteractionResponseProperties.cs index 6086167f..aef8b1f5 100644 --- a/Anarchy/REST/Interactions/InteractionResponseProperties.cs +++ b/Anarchy/REST/Interactions/InteractionResponseProperties.cs @@ -15,7 +15,6 @@ public bool Tts public bool ShouldSerializeTts() => _ttsParam.Set; - private readonly DiscordParameter _contentParam = new DiscordParameter(); [JsonProperty("content")] public string Content @@ -26,7 +25,6 @@ public string Content public bool ShouldSerializeContent() => _contentParam.Set; - private readonly DiscordParameter> _embedParam = new DiscordParameter>(); [JsonProperty("embeds")] private List _embeds => _embedParam.Value; @@ -47,7 +45,6 @@ public DiscordEmbed Embed public bool ShouldSerialize_embeds() => _embedParam.Set; - private readonly DiscordParameter> _componentParam = new DiscordParameter>(); [JsonProperty("components")] public List Components @@ -58,7 +55,6 @@ public List Components public bool ShouldSerializeComponents() => _componentParam.Set; - [JsonProperty("flags")] private int _flags { diff --git a/Anarchy/REST/Interactions/SlashCommands/ApplicationCommand.cs b/Anarchy/REST/Interactions/SlashCommands/ApplicationCommand.cs index 5872b349..efbfd7b3 100644 --- a/Anarchy/REST/Interactions/SlashCommands/ApplicationCommand.cs +++ b/Anarchy/REST/Interactions/SlashCommands/ApplicationCommand.cs @@ -21,7 +21,6 @@ public class ApplicationCommand : Controllable [JsonProperty("options")] public IReadOnlyList Options { get; private set; } - private void Update(ApplicationCommand updated) { Name = updated.Name; @@ -29,7 +28,6 @@ private void Update(ApplicationCommand updated) Options = updated.Options; } - public async Task UpdateAsync() => Update(await Client.GetGlobalCommandAsync(ApplicationId, Id)); public void Update() => UpdateAsync().GetAwaiter().GetResult(); diff --git a/Anarchy/REST/Interactions/SlashCommands/ApplicationCommandProperties.cs b/Anarchy/REST/Interactions/SlashCommands/ApplicationCommandProperties.cs index 52a689d2..0cd75a4d 100644 --- a/Anarchy/REST/Interactions/SlashCommands/ApplicationCommandProperties.cs +++ b/Anarchy/REST/Interactions/SlashCommands/ApplicationCommandProperties.cs @@ -10,19 +10,16 @@ public class ApplicationCommandProperties public bool ShouldSerializeName() => Name != null; - [JsonProperty("description")] public string Description { get; set; } public bool ShouldSerializeDescription() => Description != null; - [JsonProperty("options")] public List Options { get; set; } public bool ShouldSerializeOptions() => Options != null; - [JsonProperty("flags")] private int Flags => 64; diff --git a/Anarchy/REST/Interactions/SlashCommands/SlashCommandExtensions.cs b/Anarchy/REST/Interactions/SlashCommands/SlashCommandExtensions.cs index 758fa582..b6982a2e 100644 --- a/Anarchy/REST/Interactions/SlashCommands/SlashCommandExtensions.cs +++ b/Anarchy/REST/Interactions/SlashCommands/SlashCommandExtensions.cs @@ -10,31 +10,26 @@ public static async Task> GetGlobalCommandsAsy public static IReadOnlyList GetGlobalCommands(this DiscordClient client, ulong appId) => client.GetGlobalCommandsAsync(appId).GetAwaiter().GetResult(); - public static async Task GetGlobalCommandAsync(this DiscordClient client, ulong appId, ulong commandId) => (await client.HttpClient.GetAsync($"/applications/{appId}/commands/{commandId}")).Deserialize().SetClient(client); public static ApplicationCommand GetApplicationCommand(this DiscordClient client, ulong appId, ulong commandId) => client.GetGlobalCommandAsync(appId, commandId).GetAwaiter().GetResult(); - public static async Task CreateGlobalCommandAsync(this DiscordClient client, ulong appId, ApplicationCommandProperties properties) => (await client.HttpClient.PostAsync($"/applications/{appId}/commands", properties)).Deserialize().SetClient(client); public static ApplicationCommand CreateGlobalCommand(this DiscordClient client, ulong appId, ApplicationCommandProperties properties) => client.CreateGlobalCommandAsync(appId, properties).GetAwaiter().GetResult(); - public static async Task> SetGlobalApplicationCommandsAsync(this DiscordClient client, ulong appId, List commands) => (await client.HttpClient.PutAsync($"/applications/{appId}/commands", commands)).Deserialize>().SetClientsInList(client); public static IReadOnlyList SetGlobalApplicationCommands(this DiscordClient client, ulong appId, List commands) => client.SetGlobalApplicationCommandsAsync(appId, commands).GetAwaiter().GetResult(); - public static async Task ModifyGlobalCommandAsync(this DiscordClient client, ulong appId, ulong commandId, ApplicationCommandProperties properties) => (await client.HttpClient.PatchAsync($"/applications/{appId}/commands/{commandId}", properties)).Deserialize().SetClient(client); public static ApplicationCommand ModifyGlobalCommand(this DiscordClient client, ulong appId, ulong commandId, ApplicationCommandProperties properties) => client.ModifyGlobalCommandAsync(appId, commandId, properties).GetAwaiter().GetResult(); - public static Task DeleteGlobalCommandAsync(this DiscordClient client, ulong appId, ulong commandId) => client.HttpClient.DeleteAsync($"/applications/{appId}/commands/{commandId}"); public static void DeleteGlobalCommand(this DiscordClient client, ulong appId, ulong commandId) => client.DeleteGlobalCommandAsync(appId, commandId).GetAwaiter().GetResult(); } diff --git a/Anarchy/REST/Invite/Extensions.cs b/Anarchy/REST/Invite/Extensions.cs index ca476d16..09fc63c7 100644 --- a/Anarchy/REST/Invite/Extensions.cs +++ b/Anarchy/REST/Invite/Extensions.cs @@ -25,7 +25,6 @@ public static DiscordInvite CreateInvite(this DiscordClient client, ulong channe return client.CreateInviteAsync(channelId, properties).GetAwaiter().GetResult(); } - public static async Task DeleteInviteAsync(this DiscordClient client, string invCode) { return (await client.HttpClient.DeleteAsync($"/invites/{invCode}")) @@ -42,7 +41,6 @@ public static DiscordInvite DeleteInvite(this DiscordClient client, string invCo return client.DeleteInviteAsync(invCode).GetAwaiter().GetResult(); } - public static async Task GetInviteAsync(this DiscordClient client, string invCode) { return (await client.HttpClient.GetAsync($"/invites/{invCode}?with_counts=true")) @@ -57,7 +55,6 @@ public static DiscordInvite GetInvite(this DiscordClient client, string invCode) return client.GetInviteAsync(invCode).GetAwaiter().GetResult(); } - public static async Task> GetGuildInvitesAsync(this DiscordClient client, ulong guildId) { return (await client.HttpClient.GetAsync($"/guilds/{guildId}/invites")).Deserialize>().SetClientsInList(client); diff --git a/Anarchy/REST/Invite/Models/DiscordInvite.cs b/Anarchy/REST/Invite/Models/DiscordInvite.cs index c28bd110..1fec5c0a 100644 --- a/Anarchy/REST/Invite/Models/DiscordInvite.cs +++ b/Anarchy/REST/Invite/Models/DiscordInvite.cs @@ -15,30 +15,24 @@ public DiscordInvite() }; } - [JsonProperty("code")] public string Code { get; private set; } - [JsonProperty("channel")] [JsonConverter(typeof(DeepJsonConverter))] public DiscordChannel Channel { get; private set; } - [JsonProperty("inviter")] public DiscordUser Inviter { get; private set; } - [JsonProperty("guild")] protected InviteGuild _guild; - public InviteType Type { get { return _guild != null ? InviteType.Guild : InviteType.Group; } } - public async Task DeleteAsync() { Inviter = (await Client.DeleteInviteAsync(Code)).Inviter; @@ -53,7 +47,6 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public async Task JoinAsync() { if (Type == InviteType.Guild) @@ -67,7 +60,6 @@ public void Join() JoinAsync().GetAwaiter().GetResult(); } - public override string ToString() { return Code; diff --git a/Anarchy/REST/Invite/Models/GuildInvite.cs b/Anarchy/REST/Invite/Models/GuildInvite.cs index 03226226..b4a3ea8a 100644 --- a/Anarchy/REST/Invite/Models/GuildInvite.cs +++ b/Anarchy/REST/Invite/Models/GuildInvite.cs @@ -10,7 +10,7 @@ public GuildInvite() { if (_guild != null) { - ((GuildChannel)Channel).GuildId = _guild.Id; + ((GuildChannel) Channel).GuildId = _guild.Id; _guild.SetClient(Client); } }; @@ -21,19 +21,15 @@ public GuildInvite() [JsonProperty("temporary")] public bool Temporary { get; private set; } - [JsonProperty("uses")] public uint Uses { get; private set; } - [JsonProperty("max_uses")] public uint MaxUses { get; private set; } - [JsonProperty("approximate_presence_count")] public uint OnlineMembers { get; private set; } - [JsonProperty("approximate_member_count")] public uint TotalMembers { get; private set; } } diff --git a/Anarchy/REST/Invite/Models/InviteGuild.cs b/Anarchy/REST/Invite/Models/InviteGuild.cs index a34d184a..ab76e9e1 100644 --- a/Anarchy/REST/Invite/Models/InviteGuild.cs +++ b/Anarchy/REST/Invite/Models/InviteGuild.cs @@ -8,7 +8,6 @@ public class InviteGuild : BaseGuild [JsonProperty("description")] public string Description { get; protected set; } - [JsonProperty("splash")] private string _splashHash; @@ -23,19 +22,15 @@ public DiscordCDNImage Splash } } - [JsonProperty("features")] public IReadOnlyList Features { get; private set; } - [JsonProperty("vanity_url_code")] public string VanityInvite { get; private set; } - [JsonProperty("verification_level")] public GuildVerificationLevel VerificationLevel { get; private set; } - protected void Update(InviteGuild guild) { base.Update(guild); diff --git a/Anarchy/REST/Invite/Models/InviteProperties.cs b/Anarchy/REST/Invite/Models/InviteProperties.cs index 59cc72a8..33c16782 100644 --- a/Anarchy/REST/Invite/Models/InviteProperties.cs +++ b/Anarchy/REST/Invite/Models/InviteProperties.cs @@ -10,11 +10,9 @@ public class InviteProperties [JsonProperty("max_age")] public uint MaxAge { get; set; } - [JsonProperty("max_uses")] public uint MaxUses { get; set; } - [JsonProperty("temporary")] public bool Temporary { get; set; } } diff --git a/Anarchy/REST/Message/Extensions.cs b/Anarchy/REST/Message/Extensions.cs index 5fac3327..cd52a404 100644 --- a/Anarchy/REST/Message/Extensions.cs +++ b/Anarchy/REST/Message/Extensions.cs @@ -80,7 +80,6 @@ public static DiscordMessage SendFile(this DiscordClient client, ulong channelId return client.SendFileAsync(channelId, fileName, fileData, message, tts).GetAwaiter().GetResult(); } - public static async Task SendFileAsync(this DiscordClient client, ulong channelId, string filePath, string message = null, bool tts = false) { return await client.SendFileAsync(channelId, Path.GetFileName(filePath), File.ReadAllBytes(filePath), message, tts); @@ -98,7 +97,6 @@ public static DiscordMessage SendFile(this DiscordClient client, ulong channelId return client.SendFileAsync(channelId, filePath, message, tts).GetAwaiter().GetResult(); } - public static async Task EditMessageAsync(this DiscordClient client, ulong channelId, ulong messageId, MessageEditProperties properties) { return (await client.HttpClient.PatchAsync($"/channels/{channelId}/messages/{messageId}", properties)) @@ -117,7 +115,6 @@ public static DiscordMessage EditMessage(this DiscordClient client, ulong channe return client.EditMessageAsync(channelId, messageId, properties).GetAwaiter().GetResult(); } - public static async Task DeleteMessageAsync(this DiscordClient client, ulong channelId, ulong messageId) { await client.HttpClient.DeleteAsync($"/channels/{channelId}/messages/{messageId}"); @@ -133,7 +130,6 @@ public static void DeleteMessage(this DiscordClient client, ulong channelId, ulo client.DeleteMessageAsync(channelId, messageId).GetAwaiter().GetResult(); } - public static async Task DeleteMessagesAsync(this DiscordClient client, ulong channelId, List messages) { await client.HttpClient.PostAsync($"/channels/{channelId}/messages/bulk-delete", $"{{\"messages\":{JsonConvert.SerializeObject(messages)}}}"); @@ -150,7 +146,6 @@ public static void DeleteMessages(this DiscordClient client, ulong channelId, Li } #endregion - public static async Task TriggerTypingAsync(this DiscordClient client, ulong channelId) { var resp = await client.HttpClient.PostAsync($"/channels/{channelId}/typing"); @@ -168,7 +163,6 @@ public static void TriggerTyping(this DiscordClient client, ulong channelId) client.TriggerTypingAsync(channelId).GetAwaiter().GetResult(); } - /// /// Gets a list of messages from a channel. /// The list is ordered first -> last. @@ -187,7 +181,7 @@ public static async Task> GetChannelMessagesAsync( while (true) { string parameters = ""; - if (filters.Limit.HasValue) parameters += $"limit={(uint)Math.Min(messagesPerRequest, filters.Limit.Value - messages.Count)}&"; + if (filters.Limit.HasValue) parameters += $"limit={(uint) Math.Min(messagesPerRequest, filters.Limit.Value - messages.Count)}&"; else parameters += $"limit={messagesPerRequest}&"; if (filters.BeforeId.HasValue) parameters += $"before={filters.BeforeId.Value}&"; if (filters.AfterId.HasValue) parameters += $"after={filters.AfterId.Value}&"; @@ -215,7 +209,6 @@ public static IReadOnlyList GetChannelMessages(this DiscordClien return client.GetChannelMessagesAsync(channelId, filters).GetAwaiter().GetResult(); } - /// /// Gets a list of messages from a channel /// @@ -231,7 +224,6 @@ public static IReadOnlyList GetChannelMessages(this DiscordClien return client.GetChannelMessagesAsync(channelId, limit).GetAwaiter().GetResult(); } - public static async Task> GetMessageReactionsAsync(this DiscordClient client, ulong channelId, ulong messageId, ReactionQuery query) { return (await client.HttpClient.GetAsync($"/channels/{channelId}/messages/{messageId}/reactions/{query.ReactionName}{(query.ReactionId.HasValue ? ":" + query.ReactionId.Value : "")}?limit={query.Limit}&after={query.AfterId}")) @@ -251,7 +243,6 @@ public static IReadOnlyList GetMessageReactions(this DiscordClient return client.GetMessageReactionsAsync(channelId, messageId, query).GetAwaiter().GetResult(); } - public static async Task AddMessageReactionAsync(this DiscordClient client, ulong channelId, ulong messageId, string reactionName, ulong? reactionId = null) { await client.HttpClient.PutAsync($"/channels/{channelId}/messages/{messageId}/reactions/{reactionName}{(reactionId.HasValue ? ":" + reactionId.Value : "")}/@me"); @@ -268,13 +259,11 @@ public static void AddMessageReaction(this DiscordClient client, ulong channelId client.AddMessageReactionAsync(channelId, messageId, reactionName, reactionId).GetAwaiter().GetResult(); } - private static async Task removeReactionAsync(this DiscordClient client, ulong channelId, ulong messageId, string user, string reactionName, ulong? reactionId = null) { await client.HttpClient.DeleteAsync($"/channels/{channelId}/messages/{messageId}/reactions/{reactionName}{(reactionId.HasValue ? ":" + reactionId.Value : "")}/{user}"); } - public static async Task RemoveMessageReactionAsync(this DiscordClient client, ulong channelId, ulong messageId, string reactionName, ulong? reactionId = null) { await client.removeReactionAsync(channelId, messageId, "@me", reactionName, reactionId); @@ -285,7 +274,6 @@ public static void RemoveMessageReaction(this DiscordClient client, ulong channe client.RemoveMessageReactionAsync(channelId, messageId, reactionName, reactionId).GetAwaiter().GetResult(); } - public static async Task RemoveMessageReactionAsync(this DiscordClient client, ulong channelId, ulong messageId, ulong userId, string reactionName, ulong? reactionId = null) { await client.removeReactionAsync(channelId, messageId, userId.ToString(), reactionName, reactionId); @@ -296,7 +284,6 @@ public static void RemoveMessageReaction(this DiscordClient client, ulong channe client.RemoveMessageReactionAsync(channelId, messageId, userId, reactionName, reactionId).GetAwaiter().GetResult(); } - #region pins [Obsolete("GetChannelPinnedMessagesAsync is depricated. Call GetPinnedMessagesAsync instead", true)] public static Task> GetChannelPinnedMessagesAsync(this DiscordClient client, ulong channelId) @@ -325,7 +312,6 @@ public static IReadOnlyList GetPinnedMessages(this DiscordClient return client.GetPinnedMessagesAsync(channelId).GetAwaiter().GetResult(); } - [Obsolete("PinChannelMessageAsync is depricated. Call PinMessageAsync instead", true)] public static Task PinChannelMessageAsync(this DiscordClient client, ulong channelId, ulong messageId) { @@ -353,7 +339,6 @@ public static void PinMessage(this DiscordClient client, ulong channelId, ulong client.PinMessageAsync(channelId, messageId).GetAwaiter().GetResult(); } - public static async Task UnpinChannelMessageAsync(this DiscordClient client, ulong channelId, ulong messageId) { await client.HttpClient.DeleteAsync($"/channels/{channelId}/pins/{messageId}"); @@ -370,7 +355,6 @@ public static void UnpinChannelMessage(this DiscordClient client, ulong channelI } #endregion - public static async Task CrosspostMessageAsync(this DiscordClient client, ulong channelId, ulong messageId) { return (await client.HttpClient.PostAsync($"/channels/{channelId}/messages/{messageId}/crosspost")).Deserialize().SetClient(client); @@ -381,7 +365,6 @@ public static DiscordMessage CrosspostMessage(this DiscordClient client, ulong c return client.CrosspostMessageAsync(channelId, messageId).GetAwaiter().GetResult(); } - public static async Task AcknowledgeMessageAsync(this DiscordClient client, ulong channelId, ulong messageId) { await client.HttpClient.PostAsync($"/channels/{channelId}/messages/{messageId}/ack", "{\"token\":null}"); @@ -392,7 +375,6 @@ public static void AcknowledgeMessage(this DiscordClient client, ulong channelId client.AcknowledgeMessageAsync(channelId, messageId).GetAwaiter().GetResult(); } - public static async Task GetAttachmentFile(this DiscordAttachment _this) { using var hc = new HttpClient(); diff --git a/Anarchy/REST/Message/Message/DeletedMessage.cs b/Anarchy/REST/Message/Message/DeletedMessage.cs index e4c19256..f081539d 100644 --- a/Anarchy/REST/Message/Message/DeletedMessage.cs +++ b/Anarchy/REST/Message/Message/DeletedMessage.cs @@ -7,13 +7,11 @@ public class DeletedMessage : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; public MinimalTextChannel Channel => new MinimalTextChannel(_channelId).SetClient(Client); - [JsonProperty("guild_id")] private readonly ulong _guildId; @@ -25,7 +23,6 @@ public MinimalGuild Guild } } - public static implicit operator ulong(DeletedMessage instance) { return instance.Id; diff --git a/Anarchy/REST/Message/Message/DiscordAttachment.cs b/Anarchy/REST/Message/Message/DiscordAttachment.cs index 43b619a2..0eeb0fb9 100644 --- a/Anarchy/REST/Message/Message/DiscordAttachment.cs +++ b/Anarchy/REST/Message/Message/DiscordAttachment.cs @@ -7,31 +7,24 @@ public class DiscordAttachment [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("filename")] public string FileName { get; private set; } - [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("content_type")] public string ContentType { get; private set; } - [JsonProperty("url")] public string Url { get; private set; } - [JsonProperty("proxy_url")] public string ProxyUrl { get; private set; } - [JsonProperty("size")] public uint FileSize { get; private set; } - public override string ToString() { return Url; diff --git a/Anarchy/REST/Message/Message/DiscordMessage.cs b/Anarchy/REST/Message/Message/DiscordMessage.cs index 023349d9..41987d40 100644 --- a/Anarchy/REST/Message/Message/DiscordMessage.cs +++ b/Anarchy/REST/Message/Message/DiscordMessage.cs @@ -31,27 +31,21 @@ public DiscordMessage() }; } - [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("content")] public string Content { get; private set; } - [JsonProperty("tts")] public bool Tts { get; private set; } - [JsonProperty("author")] private DiscordUser _authorUser; - [JsonProperty("member")] private GuildMember _authorMember; - public MessageAuthor Author { get @@ -63,11 +57,9 @@ public MessageAuthor Author } } - [JsonProperty("attachments")] public IReadOnlyList Attachments { get; private set; } - [JsonProperty("embeds")] private IReadOnlyList _embeds; public DiscordEmbed Embed @@ -76,45 +68,35 @@ public DiscordEmbed Embed private set { _embeds = new List() { value }; } } - [JsonProperty("reactions")] public IReadOnlyList Reactions { get; private set; } - [JsonProperty("mentions")] public IReadOnlyList Mentions { get; private set; } - [JsonProperty("mention_roles")] public IReadOnlyList MentionedRoles { get; private set; } - [JsonProperty("mention_everyone")] public bool MentionedEveryone { get; private set; } - [JsonProperty("timestamp")] public DateTime SentAt { get; private set; } - [JsonProperty("edited_timestamp")] public DateTime? EditedAt { get; private set; } - [JsonProperty("pinned")] public bool Pinned { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; public MinimalTextChannel Channel => new MinimalTextChannel(_channelId).SetClient(Client); - [JsonProperty("guild_id")] internal ulong? GuildId { get; set; } - /// /// This is sometimes null, even when it has been sent through a guild /// @@ -129,31 +111,25 @@ public MinimalGuild Guild } } - [JsonProperty("type")] public MessageType Type { get; private set; } - [JsonProperty("flags")] public MessageFlags Flags { get; private set; } - [JsonProperty("referenced_message")] public DiscordMessage ReferencedMessage { get; private set; } [JsonProperty("message_reference")] public MessageReference MessageReference { get; private set; } - [JsonProperty("components")] [JsonConverter(typeof(DeepJsonConverter))] public List Components { get; private set; } - [JsonProperty("sticker_items")] public IReadOnlyList Stickers { get; private set; } - private void Update(DiscordMessage updated) { Content = updated.Content; @@ -172,7 +148,6 @@ private void Update(DiscordMessage updated) _authorUser = updated.Author.User; } - public async Task EditAsync(MessageEditProperties properties) { if (Type != MessageType.Default) @@ -190,7 +165,6 @@ public void Edit(MessageEditProperties properties) EditAsync(properties).GetAwaiter().GetResult(); } - public async Task DeleteAsync() { await Client.DeleteMessageAsync(Channel.Id, Id); @@ -204,7 +178,6 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public async Task AcknowledgeAsync() { await Client.AcknowledgeMessageAsync(Channel.Id, Id); @@ -215,7 +188,6 @@ public void Acknowledge() AcknowledgeAsync().GetAwaiter().GetResult(); } - public async Task> GetReactionsAsync(ReactionQuery query) { return await Client.GetMessageReactionsAsync(Channel.Id, Id, query); @@ -232,7 +204,6 @@ public IReadOnlyList GetReactions(ReactionQuery query) return GetReactionsAsync(query).GetAwaiter().GetResult(); } - public async Task AddReactionAsync(string reactionName, ulong? reactionId = null) { await Client.AddMessageReactionAsync(Channel.Id, Id, reactionName, reactionId); @@ -246,7 +217,6 @@ public void AddReaction(string reactionName, ulong? reactionId = null) AddReactionAsync(reactionName, reactionId).GetAwaiter().GetResult(); } - public async Task RemoveClientReactionAsync(string reactionName, ulong? reactionId = null) { await Client.RemoveMessageReactionAsync(Channel.Id, Id, reactionName, reactionId); @@ -257,7 +227,6 @@ public void RemoveClientReaction(string reactionName, ulong? reactionId = null) RemoveClientReactionAsync(reactionName, reactionId).GetAwaiter().GetResult(); } - public async Task RemoveReactionAsync(ulong userId, string reactionName, ulong? reactionId = null) { await Client.RemoveMessageReactionAsync(Channel.Id, Id, userId, reactionName, reactionId); @@ -268,7 +237,6 @@ public void RemoveReaction(ulong userId, string reactionName, ulong? reactionId RemoveReactionAsync(userId, reactionName, reactionId).GetAwaiter().GetResult(); } - public async Task PinAsync() { await Channel.PinMessageAsync(Id); @@ -279,7 +247,6 @@ public void Pin() PinAsync().GetAwaiter().GetResult(); } - public async Task CrosspostAsync() { Update(await Client.CrosspostMessageAsync(Channel.Id, Id)); @@ -290,7 +257,6 @@ public void Crosspost() CrosspostAsync().GetAwaiter().GetResult(); } - public static implicit operator ulong(DiscordMessage instance) { return instance.Id; diff --git a/Anarchy/REST/Message/Message/MessageAuthor.cs b/Anarchy/REST/Message/Message/MessageAuthor.cs index a4020b37..902d01f6 100644 --- a/Anarchy/REST/Message/Message/MessageAuthor.cs +++ b/Anarchy/REST/Message/Message/MessageAuthor.cs @@ -12,7 +12,6 @@ internal MessageAuthor(DiscordUser user, GuildMember member) public DiscordUser User { get; private set; } public GuildMember Member { get; private set; } - public override string ToString() { return User.ToString(); diff --git a/Anarchy/REST/Message/Message/Properties/MessageEditProperties.cs b/Anarchy/REST/Message/Message/Properties/MessageEditProperties.cs index 216523b0..a6552883 100644 --- a/Anarchy/REST/Message/Message/Properties/MessageEditProperties.cs +++ b/Anarchy/REST/Message/Message/Properties/MessageEditProperties.cs @@ -17,7 +17,6 @@ public bool ShouldSerializeContent() return _contentProperty.Set; } - private DiscordParameter _embedProperty = new DiscordParameter(); [JsonProperty("embed")] public DiscordEmbed Embed @@ -31,7 +30,6 @@ public bool ShouldSerializeEmbed() return _embedProperty.Set; } - private DiscordParameter _flagProperty = new DiscordParameter(); [JsonProperty("flags")] public MessageFlags Flags diff --git a/Anarchy/REST/Message/Message/Properties/MessageFilters.cs b/Anarchy/REST/Message/Message/Properties/MessageFilters.cs index 29965238..92e083c8 100644 --- a/Anarchy/REST/Message/Message/Properties/MessageFilters.cs +++ b/Anarchy/REST/Message/Message/Properties/MessageFilters.cs @@ -4,22 +4,16 @@ public class MessageFilters { public MessageAttachmentFilter? Has { get; set; } - public string Content { get; set; } - public ulong? MentioningUserId { get; set; } - public ulong? AuthorId { get; set; } - public ulong? BeforeId { get; set; } - public ulong? AfterId { get; set; } - public uint? Limit { get; set; } } } diff --git a/Anarchy/REST/Message/Message/Properties/MessageProperties.cs b/Anarchy/REST/Message/Message/Properties/MessageProperties.cs index 9bedbc4a..06e01014 100644 --- a/Anarchy/REST/Message/Message/Properties/MessageProperties.cs +++ b/Anarchy/REST/Message/Message/Properties/MessageProperties.cs @@ -16,29 +16,23 @@ public MessageProperties() [JsonProperty("content")] public string Content { get; set; } - [JsonProperty("nonce")] #pragma warning disable IDE0052 private readonly string _nonce; #pragma warning restore - [JsonProperty("tts")] public bool Tts { get; set; } - [JsonProperty("message_reference")] public MessageReference ReplyTo { get; set; } - [JsonProperty("embed")] public DiscordEmbed Embed { get; set; } - [JsonProperty("components")] public List Components { get; set; } - [JsonProperty("attachments")] public List Attachments { get; set; } diff --git a/Anarchy/REST/Message/Message/Properties/PartialDiscordAttachment.cs b/Anarchy/REST/Message/Message/Properties/PartialDiscordAttachment.cs index 568be63f..330097c8 100644 --- a/Anarchy/REST/Message/Message/Properties/PartialDiscordAttachment.cs +++ b/Anarchy/REST/Message/Message/Properties/PartialDiscordAttachment.cs @@ -25,11 +25,9 @@ public PartialDiscordAttachment(DiscordAttachmentFile file, string fileName, str Description = description; } - [JsonProperty("id")] internal ulong Id { get; set; } - private string _fileName; [JsonProperty("filename")] public string FileName @@ -38,11 +36,9 @@ public string FileName set { _fileName = Path.GetFileName(value); } } - [JsonProperty("description")] public string Description { get; set; } - [JsonIgnore] public DiscordAttachmentFile File { get; set; } } diff --git a/Anarchy/REST/Message/Message/UserTyping.cs b/Anarchy/REST/Message/Message/UserTyping.cs index ecd37924..9fe656bc 100644 --- a/Anarchy/REST/Message/Message/UserTyping.cs +++ b/Anarchy/REST/Message/Message/UserTyping.cs @@ -16,7 +16,6 @@ public MinimalTextChannel Channel } } - [JsonProperty("guild_id")] private readonly ulong? _guildId; @@ -31,11 +30,9 @@ public MinimalGuild Guild } } - [JsonProperty("user_id")] public ulong UserId { get; private set; } - [JsonProperty("timestamp")] #pragma warning disable CS0649 private readonly ulong _timestamp; @@ -44,10 +41,9 @@ public MinimalGuild Guild [JsonIgnore] public DateTimeOffset Timestamp { - get { return DateTimeOffset.FromUnixTimeSeconds((long)_timestamp); } + get { return DateTimeOffset.FromUnixTimeSeconds((long) _timestamp); } } - public override string ToString() { return Timestamp.ToString(); diff --git a/Anarchy/REST/Message/Reaction/MessageReaction.cs b/Anarchy/REST/Message/Reaction/MessageReaction.cs index 59f7feef..da028144 100644 --- a/Anarchy/REST/Message/Reaction/MessageReaction.cs +++ b/Anarchy/REST/Message/Reaction/MessageReaction.cs @@ -9,19 +9,15 @@ public MessageReaction() OnClientUpdated += (sender, e) => Emoji.SetClient(Client); } - [JsonProperty("emoji")] public PartialEmoji Emoji { get; private set; } - [JsonProperty("count")] public uint Count { get; private set; } - [JsonProperty("me")] public bool ClientHasReacted { get; private set; } - public override string ToString() { return Emoji.ToString(); diff --git a/Anarchy/REST/Message/Reaction/Update.cs b/Anarchy/REST/Message/Reaction/Update.cs index 4a149155..bf96d7bb 100644 --- a/Anarchy/REST/Message/Reaction/Update.cs +++ b/Anarchy/REST/Message/Reaction/Update.cs @@ -9,15 +9,12 @@ public MessageReactionUpdate() OnClientUpdated += (sender, e) => Emoji.SetClient(Client); } - [JsonProperty("emoji")] public PartialEmoji Emoji { get; private set; } - [JsonProperty("message_id")] public ulong MessageId { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; @@ -29,7 +26,6 @@ public MinimalTextChannel Channel } } - [JsonProperty("guild_id")] private readonly ulong _guildId; @@ -41,11 +37,9 @@ public MinimalGuild Guild } } - [JsonProperty("user_id")] public ulong UserId { get; private set; } - public override string ToString() { return Emoji.ToString(); diff --git a/Anarchy/REST/OAuth2/Client/DiscordOAuth2Client.cs b/Anarchy/REST/OAuth2/Client/DiscordOAuth2Client.cs index 6bd299bd..b7b1d853 100644 --- a/Anarchy/REST/OAuth2/Client/DiscordOAuth2Client.cs +++ b/Anarchy/REST/OAuth2/Client/DiscordOAuth2Client.cs @@ -12,7 +12,7 @@ namespace Discord { public class DiscordOAuth2Client { - readonly ulong _clientId; + private readonly ulong _clientId; private readonly string _clientSecret; private DiscordOAuth2Authorization _auth; @@ -58,14 +58,12 @@ private void authorize(string grantType, Dictionary useSpecific) public void Refresh(string refreshToken) => authorize("refresh_token", new Dictionary() { { "refresh_token", refreshToken } }); public void Authorize(string code, string redirectUri) => authorize("authorization_code", new Dictionary() { { "code", code }, { "redirect_uri", redirectUri } }); - private void EnsureAuth() { if (_auth == null) throw new InvalidOperationException("You must authenticate before making this request"); else if (_auth.ExpiresAt < DateTime.UtcNow) Refresh(_auth.RefreshToken); } - private T Request(string method, string endpoint, object data = null) { EnsureAuth(); @@ -87,7 +85,6 @@ private T Request(string method, string endpoint, object data = null) return body.ToObject(); } - public DiscordUser GetUser() { if (!_auth.Scopes.Contains("identify") && !_auth.Scopes.Contains("email")) throw new InvalidOperationException("You must have the 'identify' or 'email' scope to make this request"); diff --git a/Anarchy/REST/OAuth2/Client/OAuth2GuildJoinProperties.cs b/Anarchy/REST/OAuth2/Client/OAuth2GuildJoinProperties.cs index d74e62be..8cae1b81 100644 --- a/Anarchy/REST/OAuth2/Client/OAuth2GuildJoinProperties.cs +++ b/Anarchy/REST/OAuth2/Client/OAuth2GuildJoinProperties.cs @@ -18,7 +18,6 @@ public string Nickname public bool ShouldSerializeNickname() => _nickParam.Set; - private DiscordParameter> _roleParam = new DiscordParameter>(); [JsonProperty("roles")] public List Roles @@ -29,7 +28,6 @@ public List Roles public bool ShouldSerializeRoles() => _roleParam.Set; - private DiscordParameter _muteParam = new DiscordParameter(); [JsonProperty("mute")] public bool Mute @@ -40,7 +38,6 @@ public bool Mute public bool ShouldSerializeMute() => _muteParam.Set; - private DiscordParameter _deafParam = new DiscordParameter(); [JsonProperty("deaf")] public bool Deaf diff --git a/Anarchy/REST/OAuth2/Extensions.cs b/Anarchy/REST/OAuth2/Extensions.cs index 45baca17..7e59104e 100644 --- a/Anarchy/REST/OAuth2/Extensions.cs +++ b/Anarchy/REST/OAuth2/Extensions.cs @@ -28,7 +28,6 @@ public static void DeauthorizeApp(this DiscordClient client, ulong appId) client.DeauthorizeAppAsync(appId).GetAwaiter().GetResult(); } - public static async Task AuthorizeBotAsync(this DiscordClient client, ulong botId, ulong guildId, DiscordPermission permissions, string captchaKey) { await client.HttpClient.PostAsync($"/oauth2/authorize?client_id={botId}&scope=bot", JsonConvert.SerializeObject(new DiscordBotAuthProperties() @@ -51,7 +50,6 @@ public static void AuthorizeBot(this DiscordClient client, ulong botId, ulong gu client.AuthorizeBotAsync(botId, guildId, permissions, captchaKey).GetAwaiter().GetResult(); } - public static async Task AuthorizeAppAsync(this DiscordClient client, ulong appId, string scope) { return (await client.HttpClient.PostAsync($"/oauth2/authorize?client_id={appId}&response_type=code&scope={scope}")).Deserialize().Value("location"); @@ -68,7 +66,6 @@ public static string AuthorizeApp(this DiscordClient client, ulong appId, string return client.AuthorizeAppAsync(appId, scope).GetAwaiter().GetResult(); } - public static async Task> GetApplicationsAsync(this DiscordClient client) { return (await client.HttpClient.GetAsync("/applications?with_team_applications=true")) @@ -83,7 +80,6 @@ public static IReadOnlyList GetApplications(this DiscordClien return client.GetApplicationsAsync().GetAwaiter().GetResult(); } - public static async Task GetApplicationAsync(this DiscordClient client, ulong id) { return (await client.HttpClient.GetAsync("/applications/" + id)).Deserialize().SetClient(client); @@ -98,7 +94,6 @@ public static OAuth2Application GetApplication(this DiscordClient client, ulong return client.GetApplicationAsync(id).GetAwaiter().GetResult(); } - public static async Task CreateApplicationAsync(this DiscordClient client, string name) { return (await client.HttpClient.PostAsync("/oauth2/applications", $"{{\"name\":\"{name}\"}}")) @@ -114,7 +109,6 @@ public static OAuth2Application CreateApplication(this DiscordClient client, str return client.CreateApplicationAsync(name).GetAwaiter().GetResult(); } - public static async Task ModifyApplicationAsync(this DiscordClient client, ulong id, DiscordApplicationProperties properties) { return (await client.HttpClient.PatchAsync("/applications/" + id, properties)).Deserialize().SetClient(client); @@ -130,7 +124,6 @@ public static OAuth2Application ModifyApplication(this DiscordClient client, ulo return client.ModifyApplicationAsync(id, properties).GetAwaiter().GetResult(); } - public static async Task AddBotToApplicationAsync(this DiscordClient client, ulong appId) { return (await client.HttpClient.PostAsync($"/oauth2/applications/{appId}/bot")).Deserialize().SetClient(client); @@ -146,7 +139,6 @@ public static ApplicationBot AddBotToApplication(this DiscordClient client, ulon return client.AddBotToApplicationAsync(appId).GetAwaiter().GetResult(); } - public static async Task DeleteApplicationAsync(this DiscordClient client, ulong appId) { await client.HttpClient.PostAsync($"/applications/{appId}/delete"); diff --git a/Anarchy/REST/OAuth2/Models/ApplicationBot.cs b/Anarchy/REST/OAuth2/Models/ApplicationBot.cs index 4cf0c3d5..00c5c212 100644 --- a/Anarchy/REST/OAuth2/Models/ApplicationBot.cs +++ b/Anarchy/REST/OAuth2/Models/ApplicationBot.cs @@ -8,23 +8,18 @@ public class ApplicationBot : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("username")] public string Username { get; private set; } - [JsonProperty("discriminator")] public uint Discriminator { get; private set; } - [JsonProperty("avatar")] public string AvatarId { get; private set; } - [JsonProperty("token")] public string Token { get; private set; } - public async Task AuthorizeAsync(ulong guildId, DiscordPermission permissions, string captchaKey) { await Client.AuthorizeBotAsync(Id, guildId, permissions, captchaKey); @@ -35,13 +30,11 @@ public void Authorize(ulong guildId, DiscordPermission permissions, string captc AuthorizeAsync(guildId, permissions, captchaKey).GetAwaiter().GetResult(); } - public override string ToString() { return $"{Username}#{Discriminator}"; } - public static implicit operator ulong(ApplicationBot instance) { return instance.Id; diff --git a/Anarchy/REST/OAuth2/Models/AuthorizedApp.cs b/Anarchy/REST/OAuth2/Models/AuthorizedApp.cs index 596ecf6c..388e875e 100644 --- a/Anarchy/REST/OAuth2/Models/AuthorizedApp.cs +++ b/Anarchy/REST/OAuth2/Models/AuthorizedApp.cs @@ -9,15 +9,12 @@ public class AuthorizedApp : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("scopes")] public IReadOnlyList Scopes { get; private set; } - [JsonProperty("application")] public OAuth2Application Application { get; private set; } - public async Task DeauthorizeAsync() { await Client.DeauthorizeAppAsync(Id); @@ -28,7 +25,6 @@ public void Deauthorize() DeauthorizeAsync().GetAwaiter().GetResult(); } - public static implicit operator ulong(AuthorizedApp instance) { return instance.Id; diff --git a/Anarchy/REST/OAuth2/Models/DiscordApplicationProperties.cs b/Anarchy/REST/OAuth2/Models/DiscordApplicationProperties.cs index 680a073b..311e06b1 100644 --- a/Anarchy/REST/OAuth2/Models/DiscordApplicationProperties.cs +++ b/Anarchy/REST/OAuth2/Models/DiscordApplicationProperties.cs @@ -13,13 +13,11 @@ public string Name set { _nameProperty.Value = value; } } - public bool ShouldSerializeName() { return _nameProperty.Set; } - private readonly DiscordParameter _descriptionProperty = new DiscordParameter(); [JsonProperty("description")] public string Description @@ -28,13 +26,11 @@ public string Description set { _descriptionProperty.Value = value; } } - public bool ShouldSerializeDescription() { return _descriptionProperty.Set; } - private readonly DiscordParameter IconProperty = new DiscordParameter(); [JsonProperty("icon")] public DiscordImage Icon @@ -48,7 +44,6 @@ public bool ShouldSerializeIcon() return IconProperty.Set; } - private readonly DiscordParameter _publicProperty = new DiscordParameter(); [JsonProperty("bot_public")] public bool PublicBot @@ -57,13 +52,11 @@ public bool PublicBot set { _publicProperty.Value = value; } } - public bool ShouldSerializePublicBot() { return _publicProperty.Set; } - private readonly DiscordParameter _codeGrantProperty = new DiscordParameter(); [JsonProperty("bot_require_code_grant")] public bool BotRequireCodeGrant @@ -72,13 +65,11 @@ public bool BotRequireCodeGrant set { _codeGrantProperty.Value = value; } } - public bool ShouldSerializeBotRequireCodeGrant() { return _codeGrantProperty.Set; } - private readonly DiscordParameter> _redirectsProperty = new DiscordParameter>(); [JsonProperty("redirect_urls")] public List RedirectUrls @@ -87,7 +78,6 @@ public List RedirectUrls set { _redirectsProperty.Value = value; } } - public bool ShouldSerializeRedirectUrls() { return _redirectsProperty.Set; diff --git a/Anarchy/REST/OAuth2/Models/DiscordBotAuthProperties.cs b/Anarchy/REST/OAuth2/Models/DiscordBotAuthProperties.cs index 7363c008..d3517c82 100644 --- a/Anarchy/REST/OAuth2/Models/DiscordBotAuthProperties.cs +++ b/Anarchy/REST/OAuth2/Models/DiscordBotAuthProperties.cs @@ -9,15 +9,12 @@ internal class DiscordBotAuthProperties private readonly bool _auth = true; #pragma warning restore IDE0051, CS0414 - [JsonProperty("bot_guild_id")] public ulong GuildId { get; set; } - [JsonProperty("captcha_key")] public string CaptchaKey { get; set; } - [JsonProperty("permissions")] public DiscordPermission Permissions { get; set; } } diff --git a/Anarchy/REST/OAuth2/Models/OAuth2Application.cs b/Anarchy/REST/OAuth2/Models/OAuth2Application.cs index 0df97f3b..050b1ed3 100644 --- a/Anarchy/REST/OAuth2/Models/OAuth2Application.cs +++ b/Anarchy/REST/OAuth2/Models/OAuth2Application.cs @@ -15,15 +15,12 @@ public OAuth2Application() }; } - [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("icon")] private string _iconHash; @@ -38,39 +35,30 @@ public DiscordCDNImage Icon } } - [JsonProperty("description")] public string Description { get; private set; } - [JsonProperty("summary")] public string Summary { get; private set; } - [JsonProperty("verify_key")] public string VerifyKey { get; private set; } - [JsonProperty("bot_public")] public bool PublicBot { get; private set; } - [JsonProperty("bot_require_code_grant")] public bool RequiresCodeGrant { get; private set; } - [JsonProperty("owner")] public DiscordUser Owner { get; private set; } - [JsonProperty("bot")] public ApplicationBot Bot { get; private set; } - [JsonProperty("redirect_uris")] public IReadOnlyList RedirectUris { get; private set; } - private void Update(OAuth2Application app) { Name = app.Name; @@ -85,7 +73,6 @@ private void Update(OAuth2Application app) RedirectUris = app.RedirectUris; } - public async Task UpdateAsync() { Update(await Client.GetApplicationAsync(Id)); @@ -96,7 +83,6 @@ public void Update() UpdateAsync().GetAwaiter().GetResult(); } - public async Task ModifyAsync(DiscordApplicationProperties properties) { Update(await Client.ModifyApplicationAsync(Id, properties)); @@ -107,13 +93,11 @@ public void Modify(DiscordApplicationProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public ApplicationBot AddBot() { return Bot = Client.AddBotToApplication(Id); } - public async Task DeleteAsync() { await Client.DeleteApplicationAsync(Id); @@ -124,7 +108,6 @@ public void Delete() DeleteAsync().GetAwaiter().GetResult(); } - public static implicit operator ulong(OAuth2Application instance) { return instance.Id; diff --git a/Anarchy/REST/Relationships/Extensions.cs b/Anarchy/REST/Relationships/Extensions.cs index f46d6b7a..33307b6c 100644 --- a/Anarchy/REST/Relationships/Extensions.cs +++ b/Anarchy/REST/Relationships/Extensions.cs @@ -19,7 +19,6 @@ public static IReadOnlyList GetRelationships(this DiscordCl return client.GetRelationshipsAsync().GetAwaiter().GetResult(); } - public static async Task SendFriendRequestAsync(this DiscordClient client, ulong userId) { await client.HttpClient.PutAsync("/users/@me/relationships/" + userId); @@ -30,7 +29,6 @@ public static void SendFriendRequest(this DiscordClient client, ulong userId) client.SendFriendRequestAsync(userId).GetAwaiter().GetResult(); } - public static async Task SendFriendRequestAsync(this DiscordClient client, string username, uint discriminator) { await client.HttpClient.PostAsync("/users/@me/relationships", $"{{\"username\":\"{username}\",\"discriminator\":{discriminator}}}"); @@ -44,7 +42,6 @@ public static void SendFriendRequest(this DiscordClient client, string username, client.SendFriendRequestAsync(username, discriminator).GetAwaiter().GetResult(); } - public static async Task BlockUserAsync(this DiscordClient client, ulong userId) { await client.HttpClient.PutAsync($"/users/@me/relationships/{userId}", new DiscordRelationship() { Type = RelationshipType.Blocked }); @@ -59,7 +56,6 @@ public static void BlockUser(this DiscordClient client, ulong userId) client.BlockUserAsync(userId).GetAwaiter().GetResult(); } - public static async Task RemoveRelationshipAsync(this DiscordClient client, ulong userId) { await client.HttpClient.DeleteAsync($"/users/@me/relationships/{userId}"); @@ -74,7 +70,6 @@ public static void RemoveRelationship(this DiscordClient client, ulong userId) client.RemoveRelationshipAsync(userId).GetAwaiter().GetResult(); } - public static async Task GetProfileAsync(this DiscordClient client, ulong userId) { return (await client.HttpClient.GetAsync($"/users/{userId}/profile?with_mutual_guilds=true")) @@ -90,7 +85,6 @@ public static DiscordProfile GetProfile(this DiscordClient client, ulong userId) return client.GetProfileAsync(userId).GetAwaiter().GetResult(); } - public static async Task> GetMutualFriendsAsync(this DiscordClient client, ulong userId) { return (await client.HttpClient.GetAsync($"/users/{userId}/relationships")) diff --git a/Anarchy/REST/Relationships/Models/DiscordRelationship.cs b/Anarchy/REST/Relationships/Models/DiscordRelationship.cs index 43d5077b..6698f613 100644 --- a/Anarchy/REST/Relationships/Models/DiscordRelationship.cs +++ b/Anarchy/REST/Relationships/Models/DiscordRelationship.cs @@ -13,11 +13,9 @@ public DiscordRelationship() [JsonProperty("user")] public DiscordUser User { get; private set; } - [JsonProperty("type")] public RelationshipType Type { get; internal set; } - public async Task RemoveAsync() { await Client.RemoveRelationshipAsync(User.Id); @@ -28,13 +26,11 @@ public void Remove() RemoveAsync().GetAwaiter().GetResult(); } - public override string ToString() { return $"{Type} {User}"; } - public static implicit operator ulong(DiscordRelationship instance) { return instance.User.Id; diff --git a/Anarchy/REST/Subscriptions/Nitro/DiscordBoostSlot.cs b/Anarchy/REST/Subscriptions/Nitro/DiscordBoostSlot.cs index 8f1efb5c..76b849d1 100644 --- a/Anarchy/REST/Subscriptions/Nitro/DiscordBoostSlot.cs +++ b/Anarchy/REST/Subscriptions/Nitro/DiscordBoostSlot.cs @@ -13,19 +13,15 @@ public DiscordBoostSlot() [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("subscription_id")] public ulong ActiveSubscriptionId { get; private set; } - [JsonProperty("premium_guild_subscription")] public DiscordGuildSubscription GuildSubscription { get; private set; } - [JsonProperty("canceled")] public bool Canceled { get; private set; } - [JsonProperty("cooldown_ends_at")] public DateTime? Cooldown { get; private set; } diff --git a/Anarchy/REST/Subscriptions/Nitro/DiscordGuildSubscription.cs b/Anarchy/REST/Subscriptions/Nitro/DiscordGuildSubscription.cs index 7a2d2513..a5f4dd5b 100644 --- a/Anarchy/REST/Subscriptions/Nitro/DiscordGuildSubscription.cs +++ b/Anarchy/REST/Subscriptions/Nitro/DiscordGuildSubscription.cs @@ -8,11 +8,9 @@ public class DiscordGuildSubscription : Controllable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("user_id")] public ulong UserId { get; private set; } - [JsonProperty("guild_id")] #pragma warning disable CS0649 private readonly ulong _guildId; @@ -26,11 +24,9 @@ public MinimalGuild Guild } } - [JsonProperty("ended")] public bool Ended { get; private set; } - public async Task RemoveAsync() { await Client.RemoveGuildBoostAsync(_guildId, Id); diff --git a/Anarchy/REST/Subscriptions/Nitro/Extensions.cs b/Anarchy/REST/Subscriptions/Nitro/Extensions.cs index 1dc664b9..f2026c1d 100644 --- a/Anarchy/REST/Subscriptions/Nitro/Extensions.cs +++ b/Anarchy/REST/Subscriptions/Nitro/Extensions.cs @@ -17,7 +17,6 @@ public static IReadOnlyList BoostGuild(this DiscordCli return client.BoostGuildAsync(guildId, boosts).GetAwaiter().GetResult(); } - public static async Task RemoveGuildBoostAsync(this DiscordClient client, ulong guildId, ulong subscriptionId) { await client.HttpClient.DeleteAsync($"/guilds/{guildId}/premium/subscriptions/{subscriptionId}"); @@ -28,7 +27,6 @@ public static void RemoveGuildBoost(this DiscordClient client, ulong guildId, ul client.RemoveGuildBoostAsync(guildId, subscriptionId).GetAwaiter().GetResult(); } - public static async Task> GetBoostSlotsAsync(this DiscordClient client) { return (await client.HttpClient.GetAsync("/users/@me/guilds/premium/subscription-slots")).Deserialize>().SetClientsInList(client); @@ -39,10 +37,9 @@ public static IReadOnlyList GetBoostSlots(this DiscordClient c return client.GetBoostSlotsAsync().GetAwaiter().GetResult(); } - public static async Task SetAdditionalBoostsAsync(this DiscordClient client, ulong paymentMethodId, ulong activeSubscriptionId, uint amount) { - string plan = JsonConvert.SerializeObject(new AdditionalSubscriptionPlan() { Id = DiscordNitroSubTypes.GuildBoost.SubscriptionPlanId, Quantity = (int)amount }); + string plan = JsonConvert.SerializeObject(new AdditionalSubscriptionPlan() { Id = DiscordNitroSubTypes.GuildBoost.SubscriptionPlanId, Quantity = (int) amount }); return (await client.HttpClient.PatchAsync("/users/@me/billing/subscriptions/" + activeSubscriptionId, $"{{\"payment_source_id\":{paymentMethodId},\"additional_plans\":[{plan}]}}")).Deserialize(); } diff --git a/Anarchy/REST/Subscriptions/Subscriptions/AdditionalSubscriptionPlan.cs b/Anarchy/REST/Subscriptions/Subscriptions/AdditionalSubscriptionPlan.cs index e2e6471a..973792a6 100644 --- a/Anarchy/REST/Subscriptions/Subscriptions/AdditionalSubscriptionPlan.cs +++ b/Anarchy/REST/Subscriptions/Subscriptions/AdditionalSubscriptionPlan.cs @@ -7,7 +7,6 @@ public class AdditionalSubscriptionPlan [JsonProperty("plan_id")] public ulong Id { get; set; } - [JsonProperty("quantity")] public int Quantity { get; set; } = 1; } diff --git a/Anarchy/REST/Subscriptions/Subscriptions/DiscordActiveSubscription.cs b/Anarchy/REST/Subscriptions/Subscriptions/DiscordActiveSubscription.cs index 44e40de9..58706aea 100644 --- a/Anarchy/REST/Subscriptions/Subscriptions/DiscordActiveSubscription.cs +++ b/Anarchy/REST/Subscriptions/Subscriptions/DiscordActiveSubscription.cs @@ -9,35 +9,27 @@ public class DiscordActiveSubscription [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("type")] public int Type { get; private set; } - [JsonProperty("created_at")] public DateTime CreatedAt { get; private set; } - [JsonProperty("currency")] public string Currency { get; private set; } - [JsonProperty("status")] public DiscordSubscriptionStatus Status { get; private set; } - [JsonProperty("payment_source_id")] public ulong? PaymentMethodId { get; private set; } - [JsonProperty("payment_gateway_plan_id")] public string SubscriptionTier { get; private set; } - [JsonProperty("plan_id")] public ulong PrimaryPlanId { get; private set; } - [JsonProperty("items")] public IReadOnlyList Subscriptions { get; private set; } } diff --git a/Anarchy/REST/Subscriptions/Subscriptions/DiscordSubscription.cs b/Anarchy/REST/Subscriptions/Subscriptions/DiscordSubscription.cs index 919caeee..5065f065 100644 --- a/Anarchy/REST/Subscriptions/Subscriptions/DiscordSubscription.cs +++ b/Anarchy/REST/Subscriptions/Subscriptions/DiscordSubscription.cs @@ -7,11 +7,9 @@ public class DiscordSubscription [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("plan_id")] public ulong PlanId { get; private set; } - [JsonProperty("quantity")] public int Quantity { get; private set; } } diff --git a/Anarchy/REST/Subscriptions/Subscriptions/Extensions.cs b/Anarchy/REST/Subscriptions/Subscriptions/Extensions.cs index 6c499fb1..d6bbfbfa 100644 --- a/Anarchy/REST/Subscriptions/Subscriptions/Extensions.cs +++ b/Anarchy/REST/Subscriptions/Subscriptions/Extensions.cs @@ -19,13 +19,12 @@ public static DiscordActiveSubscription GetActiveSubscription(this DiscordClient return client.GetActiveSubscriptionAsync().GetAwaiter().GetResult(); } - public static async Task PurchaseSubscriptionAsync(this DiscordClient client, ulong paymentMethodId, ulong skuId, uint additionalBoosts = 0) { List plans = new List(); if (additionalBoosts > 0) - plans.Add(new AdditionalSubscriptionPlan() { Id = DiscordNitroSubTypes.GuildBoost.SubscriptionPlanId, Quantity = (int)additionalBoosts }); + plans.Add(new AdditionalSubscriptionPlan() { Id = DiscordNitroSubTypes.GuildBoost.SubscriptionPlanId, Quantity = (int) additionalBoosts }); return (await client.HttpClient.PostAsync("/users/@me/billing/subscriptions", $"{{\"plan_id\":{skuId},\"payment_source_id\":{paymentMethodId},\"additional_plans\":{JsonConvert.SerializeObject(plans)}}}")) .Deserialize(); diff --git a/Anarchy/REST/Subscriptions/Subscriptions/SubscriptionPlan.cs b/Anarchy/REST/Subscriptions/Subscriptions/SubscriptionPlan.cs index 0e71654b..2df1b0d0 100644 --- a/Anarchy/REST/Subscriptions/Subscriptions/SubscriptionPlan.cs +++ b/Anarchy/REST/Subscriptions/Subscriptions/SubscriptionPlan.cs @@ -7,27 +7,21 @@ public class SubscriptionPlan [JsonProperty("sku_id")] public ulong SkuId { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("currency")] public string Currency { get; private set; } - [JsonProperty("price")] public int Price { get; private set; } - [JsonProperty("tax_inclusive")] public bool TaxInclusive { get; private set; } - [JsonProperty("id")] public ulong Id { get; private set; } - public static implicit operator ulong(SubscriptionPlan instance) { return instance.Id; diff --git a/Anarchy/REST/SuperProperties.cs b/Anarchy/REST/SuperProperties.cs index cf62f0b8..dd9bedf0 100644 --- a/Anarchy/REST/SuperProperties.cs +++ b/Anarchy/REST/SuperProperties.cs @@ -77,7 +77,7 @@ private static int GetClientVersion() public DiscordReleaseChannel ReleaseChannel { - get => (DiscordReleaseChannel)Enum.Parse(typeof(DiscordReleaseChannel), _relChannel, true); + get => (DiscordReleaseChannel) Enum.Parse(typeof(DiscordReleaseChannel), _relChannel, true); set => _relChannel = value.ToString().ToLower(); } @@ -87,19 +87,16 @@ public DiscordReleaseChannel ReleaseChannel [JsonProperty("client_event_source")] public string EventSource { get; set; } - public static SuperProperties FromBase64(string base64) { return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(Convert.FromBase64String(base64))); } - public string ToBase64() { return Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this))); } - public override string ToString() { return UserAgent; diff --git a/Anarchy/REST/User/Connections/ClientConnectedAccount.cs b/Anarchy/REST/User/Connections/ClientConnectedAccount.cs index 774b45b0..631c4256 100644 --- a/Anarchy/REST/User/Connections/ClientConnectedAccount.cs +++ b/Anarchy/REST/User/Connections/ClientConnectedAccount.cs @@ -8,11 +8,9 @@ public class ClientConnectedAccount : ConnectedAccount [JsonProperty("visibility")] public bool Visible { get; private set; } - [JsonProperty("show_activity")] public bool ShowAsActivity { get; private set; } - public async Task ModifyAsync(ConnectionProperties properties) { var update = await Client.ModifyConnectedAccountAsync(Type, Id, properties); @@ -28,7 +26,6 @@ public void Modify(ConnectionProperties properties) ModifyAsync(properties).GetAwaiter().GetResult(); } - public async Task RemoveAsync() { await Client.RemoveConnectedAccountAsync(Type, Id); diff --git a/Anarchy/REST/User/Connections/ConnectedAccount.cs b/Anarchy/REST/User/Connections/ConnectedAccount.cs index 2846a15e..c7cea1c6 100644 --- a/Anarchy/REST/User/Connections/ConnectedAccount.cs +++ b/Anarchy/REST/User/Connections/ConnectedAccount.cs @@ -8,26 +8,22 @@ public class ConnectedAccount : Controllable [JsonProperty("id")] public string Id { get; private set; } - [JsonProperty("type")] private readonly string _type; public ConnectedAccountType Type { get { - return (ConnectedAccountType)Enum.Parse(typeof(ConnectedAccountType), _type, true); + return (ConnectedAccountType) Enum.Parse(typeof(ConnectedAccountType), _type, true); } } - [JsonProperty("name")] public string Name { get; protected set; } - [JsonProperty("verified")] public bool Verified { get; protected set; } - public override string ToString() { return Name; diff --git a/Anarchy/REST/User/Connections/Extensions.cs b/Anarchy/REST/User/Connections/Extensions.cs index cd022809..57687f94 100644 --- a/Anarchy/REST/User/Connections/Extensions.cs +++ b/Anarchy/REST/User/Connections/Extensions.cs @@ -16,7 +16,6 @@ public static IReadOnlyList GetConnectedAccounts(this Di return client.GetConnectedAccountsAsync().GetAwaiter().GetResult(); } - public static async Task ModifyConnectedAccountAsync(this DiscordClient client, ConnectedAccountType type, string connectionId, ConnectionProperties properties) { return (await client.HttpClient.PatchAsync($"/users/@me/connections/{type.ToString().ToLower()}/{connectionId}", properties)) @@ -28,7 +27,6 @@ public static ClientConnectedAccount ModifyConnectedAccount(this DiscordClient c return client.ModifyConnectedAccountAsync(type, connectionId, properties).GetAwaiter().GetResult(); } - public static async Task RemoveConnectedAccountAsync(this DiscordClient client, ConnectedAccountType type, string id) { await client.HttpClient.DeleteAsync($"/users/@me/connections/{type.ToString().ToLower()}/{id}"); diff --git a/Anarchy/REST/User/Extensions.cs b/Anarchy/REST/User/Extensions.cs index 248370a5..7293c1c9 100644 --- a/Anarchy/REST/User/Extensions.cs +++ b/Anarchy/REST/User/Extensions.cs @@ -18,7 +18,6 @@ public static DiscordUser GetUser(this DiscordClient client, ulong userId) return client.GetUserAsync(userId).GetAwaiter().GetResult(); } - public static async Task GetClientUserAsync(this DiscordClient client) { try @@ -40,7 +39,6 @@ public static DiscordClientUser GetClientUser(this DiscordClient client) return client.GetClientUserAsync().GetAwaiter().GetResult(); } - public static Task ReportUserAsync(this DiscordClient client, DiscordReportReason reason, UserReportIdentification identification) { identification.Reason = reason; diff --git a/Anarchy/REST/User/Profile/DiscordProfile.cs b/Anarchy/REST/User/Profile/DiscordProfile.cs index 7c729f4e..f29eec73 100644 --- a/Anarchy/REST/User/Profile/DiscordProfile.cs +++ b/Anarchy/REST/User/Profile/DiscordProfile.cs @@ -16,7 +16,6 @@ public DiscordProfile() }; } - /// /// Updates the profile's info /// @@ -28,23 +27,18 @@ public void Update() ConnectedAccounts = profile.ConnectedAccounts; } - [JsonProperty("user")] public DiscordProfileUser User { get; private set; } - [JsonProperty("premium_since")] public DateTime? NitroSince { get; private set; } - [JsonProperty("mutual_guilds")] public IReadOnlyList MutualGuilds { get; private set; } - [JsonProperty("connected_accounts")] public IReadOnlyList ConnectedAccounts { get; private set; } - public override string ToString() { return User.ToString(); diff --git a/Anarchy/REST/User/Profile/MutualGuild.cs b/Anarchy/REST/User/Profile/MutualGuild.cs index 236ebb38..fa00c5ce 100644 --- a/Anarchy/REST/User/Profile/MutualGuild.cs +++ b/Anarchy/REST/User/Profile/MutualGuild.cs @@ -7,13 +7,11 @@ public class MutualGuild : MinimalGuild [JsonProperty("nick")] public string Nickname { get; private set; } - public override string ToString() { return Id.ToString(); } - public static implicit operator ulong(MutualGuild instance) { return instance.Id; diff --git a/Anarchy/REST/User/Profile/UserProfileUpdate.cs b/Anarchy/REST/User/Profile/UserProfileUpdate.cs index 37bd4863..c9ac43e9 100644 --- a/Anarchy/REST/User/Profile/UserProfileUpdate.cs +++ b/Anarchy/REST/User/Profile/UserProfileUpdate.cs @@ -15,13 +15,11 @@ public string Username set { NameProperty.Value = value; } } - public bool ShouldSerializeUsername() { return NameProperty.Set; } - internal DiscordParameter DiscriminatorProperty = new DiscordParameter(); [JsonProperty("discriminator")] public uint Discriminator @@ -30,13 +28,11 @@ public uint Discriminator set { DiscriminatorProperty.Value = value; } } - public bool ShouldSerializeDiscriminator() { return DiscriminatorProperty.Set; } - private readonly DiscordParameter EmailProperty = new DiscordParameter(); [JsonProperty("email")] public string Email @@ -45,13 +41,11 @@ public string Email set { EmailProperty.Value = value; } } - public bool ShouldSerializeEmail() { return EmailProperty.Set; } - private readonly DiscordParameter AvatarProperty = new DiscordParameter(); [JsonProperty("avatar")] public DiscordImage Avatar @@ -60,13 +54,11 @@ public DiscordImage Avatar set { AvatarProperty.Value = value; } } - public bool ShouldSerializeAvatar() { return AvatarProperty.Set; } - private readonly DiscordParameter _bioParam = new DiscordParameter(); [JsonProperty("bio")] public string Biography @@ -77,7 +69,6 @@ public string Biography public bool ShouldSerializeBiography() => _bioParam.Set; - private readonly DiscordParameter _bannerParam = new DiscordParameter(); [JsonProperty("banner")] public DiscordImage Banner @@ -88,12 +79,9 @@ public DiscordImage Banner public bool ShouldSerializeBanner() => _bannerParam.Set; - - [JsonProperty("password")] public string Password { get; set; } - [JsonProperty("new_password")] public string NewPassword { get; set; } } diff --git a/Anarchy/REST/User/Settings/CustomStatus.cs b/Anarchy/REST/User/Settings/CustomStatus.cs index 132bd970..82b8ea1c 100644 --- a/Anarchy/REST/User/Settings/CustomStatus.cs +++ b/Anarchy/REST/User/Settings/CustomStatus.cs @@ -12,17 +12,14 @@ public ulong? EmojiId set { EmojiProperty.Value = value; } } - public bool ShouldSerializeEmojiId() { return EmojiProperty.Set; } - [JsonProperty("emoji_name")] public string EmojiName { get; set; } - [JsonProperty("text")] public string Text { get; set; } } diff --git a/Anarchy/REST/User/Settings/DiscordGuildFolder.cs b/Anarchy/REST/User/Settings/DiscordGuildFolder.cs index 84a828f7..1c80b7b0 100644 --- a/Anarchy/REST/User/Settings/DiscordGuildFolder.cs +++ b/Anarchy/REST/User/Settings/DiscordGuildFolder.cs @@ -10,7 +10,6 @@ public class DiscordGuildFolder : Controllable [JsonProperty("guild_ids")] private readonly IReadOnlyList _guilds; - public IReadOnlyList Guilds { get @@ -23,15 +22,12 @@ public IReadOnlyList Guilds } } - [JsonProperty("id")] public long? Id { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - [JsonProperty("color")] private readonly int? _color; @@ -46,13 +42,11 @@ public Color? Color } } - public bool Folder { get { return Id.HasValue; } } - public DiscordGuildFolderUpdate ToUpdate() { return new DiscordGuildFolderUpdate() diff --git a/Anarchy/REST/User/Settings/DiscordGuildFolderUpdate.cs b/Anarchy/REST/User/Settings/DiscordGuildFolderUpdate.cs index 06704656..14a9f673 100644 --- a/Anarchy/REST/User/Settings/DiscordGuildFolderUpdate.cs +++ b/Anarchy/REST/User/Settings/DiscordGuildFolderUpdate.cs @@ -15,19 +15,15 @@ public DiscordGuildFolderUpdate() _rnd = new Random(); } - [JsonProperty("guild_ids")] public List Guilds { get; set; } - [JsonProperty("id")] public long? Id { get; internal set; } - [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("color")] private int? _color; @@ -53,7 +49,6 @@ public Color? Color } } - public bool Folder { get { return Id.HasValue; } @@ -62,14 +57,13 @@ public bool Folder if (value) { if (!Id.HasValue) - Id = (long)_rnd.Next(1, 999999); + Id = (long) _rnd.Next(1, 999999); } else Id = null; } } - public static List FromSettings(DiscordUserSettings settings) { return settings.GuildFolders.ToList().ConvertAll(f => f.ToUpdate()); diff --git a/Anarchy/REST/User/Settings/DiscordUserSettings.cs b/Anarchy/REST/User/Settings/DiscordUserSettings.cs index 73a78835..b73bcd65 100644 --- a/Anarchy/REST/User/Settings/DiscordUserSettings.cs +++ b/Anarchy/REST/User/Settings/DiscordUserSettings.cs @@ -13,7 +13,6 @@ public DiscordUserSettings() GuildFolders.SetClientsInList(Client); } - // Privacy & Safety [JsonProperty("explicit_content_filter")] public ExplicitContentFilter ExplicitContentFilter { get; private set; } @@ -27,17 +26,15 @@ public DiscordUserSettings() [JsonProperty("friend_source_flags")] public FriendRequestFlags FriendRequestFlags { get; private set; } - // Appearance [JsonProperty("theme")] private string _theme; - public DiscordTheme Theme => (DiscordTheme)Enum.Parse(typeof(DiscordTheme), _theme, true); + public DiscordTheme Theme => (DiscordTheme) Enum.Parse(typeof(DiscordTheme), _theme, true); [JsonProperty("message_display_compact")] public bool CompactMessages { get; private set; } - // Accessability [JsonProperty("gif_auto_play")] public bool PlayGifsAutomatically { get; private set; } @@ -51,7 +48,6 @@ public DiscordUserSettings() [JsonProperty("enable_tts_playback")] public bool EnableTts { get; private set; } - // Text and images [JsonProperty("inline_embed_media")] public bool EmbedMedia { get; private set; } @@ -68,17 +64,14 @@ public DiscordUserSettings() [JsonProperty("convert_emoticons")] public bool ConvertEmoticons { get; private set; } - // Language [JsonProperty("locale")] public DiscordLanguage Language { get; private set; } - // Advanced [JsonProperty("developer_mode")] public bool DeveloperMode { get; private set; } - // Other [JsonProperty("custom_status")] public CustomStatus CustomStatus { get; private set; } @@ -93,7 +86,6 @@ public DiscordUserSettings() private readonly List _restrictedGuilds; public IReadOnlyList RestrictedGuilds => _restrictedGuilds.Select(id => new MinimalGuild(id).SetClient(Client)).ToList(); - internal void Update(JObject jObj) { foreach (var property in this.GetType().GetProperties()) @@ -102,7 +94,7 @@ internal void Update(JObject jObj) { if (attr.GetType() == typeof(JsonPropertyAttribute)) { - var jsonAttr = (JsonPropertyAttribute)attr; + var jsonAttr = (JsonPropertyAttribute) attr; if (jObj.TryGetValue(jsonAttr.PropertyName, out JToken value)) property.SetValue(this, value.ToObject(property.PropertyType)); diff --git a/Anarchy/REST/User/Settings/UserSettingsProperties.cs b/Anarchy/REST/User/Settings/UserSettingsProperties.cs index d3e466ae..01d6e3cb 100644 --- a/Anarchy/REST/User/Settings/UserSettingsProperties.cs +++ b/Anarchy/REST/User/Settings/UserSettingsProperties.cs @@ -20,7 +20,6 @@ public bool ShouldSerializeExplicitContentFilter() return ExplicityProperty.Set; } - private readonly DiscordParameter _defaultGuildRestrictParam = new DiscordParameter(); [JsonProperty("default_guilds_restricted")] public bool RestrictGuildsByDefault @@ -31,7 +30,6 @@ public bool RestrictGuildsByDefault public bool ShouldSerializeRestrictGuildsByDefault() => _defaultGuildRestrictParam.Set; - private readonly DiscordParameter _nsfwGuildParam = new DiscordParameter(); [JsonProperty("view_nsfw_guilds")] public bool ViewNsfwGuilds @@ -42,7 +40,6 @@ public bool ViewNsfwGuilds public bool ShouldSerializeViewNsfwGuilds() => _nsfwGuildParam.Set; - private readonly DiscordParameter _friendFlags = new DiscordParameter(); [JsonProperty("friend_source_flags")] public FriendRequestFlags FriendRequestFlags @@ -53,7 +50,6 @@ public FriendRequestFlags FriendRequestFlags public bool ShouldSerializeFriendRequestFlags() => _friendFlags.Set; - // Appearance private readonly DiscordParameter ThemeProperty = new DiscordParameter(); [JsonProperty("theme")] @@ -64,7 +60,7 @@ private string _theme public DiscordTheme Theme { - get { return (DiscordTheme)Enum.Parse(typeof(DiscordTheme), _theme, true); } + get { return (DiscordTheme) Enum.Parse(typeof(DiscordTheme), _theme, true); } set { ThemeProperty.Value = value.ToString().ToLower(); } } @@ -73,7 +69,6 @@ public bool ShouldSerialize_theme() return ThemeProperty.Set; } - private readonly DiscordParameter CompactProperty = new DiscordParameter(); [JsonProperty("message_display_compact")] public bool CompactMessages @@ -87,7 +82,6 @@ public bool ShouldSerializeCompactMessages() return CompactProperty.Set; } - // Accessability private readonly DiscordParameter GifProperty = new DiscordParameter(); [JsonProperty("gif_auto_play")] @@ -97,13 +91,11 @@ public bool PlayGifsAutomatically set { GifProperty.Value = value; } } - public bool ShouldSerializePlayGifsAutomatically() { return GifProperty.Set; } - private readonly DiscordParameter _emojiProperty = new DiscordParameter(); [JsonProperty("animate_emoji")] public bool PlayAnimatedEmojis @@ -114,7 +106,6 @@ public bool PlayAnimatedEmojis public bool ShouldSerializePlayAnimatedEmojis() => _emojiProperty.Set; - private readonly DiscordParameter _stickerProperty = new DiscordParameter(); [JsonProperty("animate_stickers")] public StickerAnimationAvailability StickerAnimation @@ -125,7 +116,6 @@ public StickerAnimationAvailability StickerAnimation public bool ShouldSerializeStickerAnimation() => _stickerProperty.Set; - private readonly DiscordParameter TtsProperty = new DiscordParameter(); [JsonProperty("enable_tts_playback")] public bool EnableTts @@ -134,13 +124,11 @@ public bool EnableTts set { TtsProperty.Value = value; } } - public bool ShouldSerializeEnableTts() { return TtsProperty.Set; } - // Text and images private readonly DiscordParameter _mediaParam = new DiscordParameter(); [JsonProperty("inline_embed_media")] @@ -152,7 +140,6 @@ public bool EmbedMedia public bool ShouldSerializeEmbedMedia() => _mediaParam.Set; - private readonly DiscordParameter _attachmentParam = new DiscordParameter(); [JsonProperty("inline_attachment_media")] public bool EmbedAttachments @@ -163,7 +150,6 @@ public bool EmbedAttachments public bool ShouldSerializeEmbedAttachments() => _attachmentParam.Set; - private readonly DiscordParameter _embedParam = new DiscordParameter(); [JsonProperty("render_embeds")] public bool EmbedLinks @@ -174,7 +160,6 @@ public bool EmbedLinks public bool ShouldSerializeEmbedLinks() => _embedParam.Set; - private readonly DiscordParameter _reactionParam = new DiscordParameter(); [JsonProperty("render_reactions")] public bool ShowReactions @@ -185,7 +170,6 @@ public bool ShowReactions public bool ShouldSerializeShowReactions() => _reactionParam.Set; - private readonly DiscordParameter _emoticonParam = new DiscordParameter(); [JsonProperty("convert_emoticons")] public bool ConvertEmoticons @@ -196,7 +180,6 @@ public bool ConvertEmoticons public bool ShouldSerializeConvertEmoticons() => _emoticonParam.Set; - // Language private readonly DiscordParameter LocaleProperty = new DiscordParameter(); [JsonProperty("locale")] @@ -206,13 +189,11 @@ public DiscordLanguage Language set { LocaleProperty.Value = value; } } - public bool ShouldSerializeLanguage() { return LocaleProperty.Set; } - // Advanced private readonly DiscordParameter DevProperty = new DiscordParameter(); [JsonProperty("developer_mode")] @@ -222,13 +203,11 @@ public bool DeveloperMode set { DevProperty.Value = value; } } - public bool ShouldSerializeDeveloperMode() { return DevProperty.Set; } - // Other private readonly DiscordParameter StatusProperty = new DiscordParameter(); [JsonProperty("custom_status")] @@ -238,13 +217,11 @@ public CustomStatus CustomStatus set { StatusProperty.Value = value; } } - public bool ShouldSerializeCustomStatus() { return StatusProperty.Set; } - private readonly DiscordParameter> _folderProperty = new DiscordParameter>(); [JsonProperty("guild_folders")] public List GuildFolders @@ -253,7 +230,6 @@ public List GuildFolders set { _folderProperty.Value = value; } } - private readonly DiscordParameter> _guildRestrictParam = new DiscordParameter>(); [JsonProperty("restricted_guilds")] public List RestrictedGuilds diff --git a/Anarchy/REST/User/User/DiscordClientUser.cs b/Anarchy/REST/User/User/DiscordClientUser.cs index ab3972d6..66fcb451 100644 --- a/Anarchy/REST/User/User/DiscordClientUser.cs +++ b/Anarchy/REST/User/User/DiscordClientUser.cs @@ -11,35 +11,27 @@ public class DiscordClientUser : DiscordUser [JsonProperty("token")] internal string Token { get; private set; } - [JsonProperty("email")] public string Email { get; private set; } - [JsonProperty("verified")] public bool EmailVerified { get; private set; } - [JsonProperty("mfa_enabled")] public bool TwoFactorAuth { get; private set; } - [JsonProperty("nsfw_allowed")] public bool? NsfwAllowed { get; private set; } - [JsonProperty("phone")] public string PhoneNumber { get; private set; } - [JsonProperty("explicit_content_filter")] public ExplicitContentFilter ExplicitContentFilter { get; private set; } - [JsonProperty("locale")] public DiscordLanguage RegistrationLanguage { get; private set; } - [JsonProperty("premium_type")] private DiscordNitroType? _nitro; @@ -48,7 +40,6 @@ public DiscordNitroType Nitro get { return _nitro ?? DiscordNitroType.None; } } - internal void Update(DiscordClientUser user) { base.Update(user); @@ -60,7 +51,6 @@ internal void Update(DiscordClientUser user) _nitro = user._nitro; } - /// /// Updates the user's info /// @@ -69,7 +59,6 @@ internal void Update(DiscordClientUser user) Update(Client.GetClientUser()); } - public async Task ChangeProfileAsync(UserProfileUpdate settings) { if (settings.Email == null) @@ -96,7 +85,6 @@ public void ChangeProfile(UserProfileUpdate settings) ChangeProfileAsync(settings).GetAwaiter().GetResult(); } - public async Task GetSettingsAsync() { return (await Client.HttpClient.GetAsync("/users/@me/settings")) @@ -111,7 +99,6 @@ public DiscordUserSettings GetSettings() return GetSettingsAsync().GetAwaiter().GetResult(); } - public async Task ChangeSettingsAsync(UserSettingsProperties settings) { return (await Client.HttpClient.PatchAsync("/users/@me/settings", settings)) @@ -126,7 +113,6 @@ public DiscordUserSettings ChangeSettings(UserSettingsProperties settings) return ChangeSettingsAsync(settings).GetAwaiter().GetResult(); } - public async Task DeleteAsync(string password) { await Client.HttpClient.PostAsync("/users/@me/delete", $"{{\"password\":\"{password}\"}}"); @@ -141,7 +127,6 @@ public void Delete(string password) DeleteAsync(password).GetAwaiter().GetResult(); } - public async Task DisableAsync(string password) { await Client.HttpClient.PostAsync("/users/@me/disable", $"{{\"password\":\"{password}\"}}"); @@ -156,13 +141,12 @@ public void Disable(string password) DisableAsync(password).GetAwaiter().GetResult(); } - public async Task SetHypesquadAsync(Hypesquad house) { if (house == Hypesquad.None) await Client.HttpClient.DeleteAsync("/hypesquad/online"); else - await Client.HttpClient.PostAsync("/hypesquad/online", $"{{\"house_id\":{(int)house}}}"); + await Client.HttpClient.PostAsync("/hypesquad/online", $"{{\"house_id\":{(int) house}}}"); } /// diff --git a/Anarchy/REST/User/User/DiscordLanguage.cs b/Anarchy/REST/User/User/DiscordLanguage.cs index ff04a736..faf0203b 100644 --- a/Anarchy/REST/User/User/DiscordLanguage.cs +++ b/Anarchy/REST/User/User/DiscordLanguage.cs @@ -58,7 +58,7 @@ private DiscordLanguage FromString(string langStr) public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - writer.WriteValue(ToString((DiscordLanguage)value)); + writer.WriteValue(ToString((DiscordLanguage) value)); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) diff --git a/Anarchy/REST/User/User/DiscordUser.cs b/Anarchy/REST/User/User/DiscordUser.cs index 96d9ca3d..c68fb22c 100644 --- a/Anarchy/REST/User/User/DiscordUser.cs +++ b/Anarchy/REST/User/User/DiscordUser.cs @@ -12,19 +12,15 @@ public class DiscordUser : Controllable, IMentionable [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("username")] public string Username { get; private set; } - [JsonProperty("discriminator")] public uint Discriminator { get; private set; } - [JsonProperty("avatar")] protected string _avatarHash; - public DiscordCDNImage Avatar { get @@ -36,12 +32,10 @@ public DiscordCDNImage Avatar } } - // understanding what public flags are is difficult because of the lack of documentation [JsonProperty("public_flags")] private DiscordBadge _publicFlags; - [JsonProperty("flags")] private DiscordBadge _flags; @@ -60,11 +54,9 @@ protected set } } - [JsonProperty("bot")] private readonly bool _bot; - public DiscordUserType Type { get @@ -76,8 +68,6 @@ public DiscordUserType Type } } - - public Hypesquad Hypesquad { get @@ -96,13 +86,11 @@ public Hypesquad Hypesquad } } - public DateTimeOffset CreatedAt { - get { return DateTimeOffset.FromUnixTimeMilliseconds((long)((Id >> 22) + 1420070400000UL)); } + get { return DateTimeOffset.FromUnixTimeMilliseconds((long) ((Id >> 22) + 1420070400000UL)); } } - internal void Update(DiscordUser user) { Username = user.Username; @@ -112,7 +100,6 @@ internal void Update(DiscordUser user) _publicFlags = user._publicFlags; } - public async Task UpdateAsync() { Update(await Client.GetUserAsync(Id)); @@ -126,7 +113,6 @@ public void Update() UpdateAsync().GetAwaiter().GetResult(); } - public async Task GetProfileAsync() { return await Client.GetProfileAsync(Id); @@ -140,7 +126,6 @@ public DiscordProfile GetProfile() return GetProfileAsync().GetAwaiter().GetResult(); } - public async Task SendFriendRequestAsync() { if (Id == Client.User.Id) @@ -157,7 +142,6 @@ public void SendFriendRequest() SendFriendRequestAsync().GetAwaiter().GetResult(); } - public async Task BlockAsync() { if (Id == Client.User.Id) @@ -174,7 +158,6 @@ public void Block() BlockAsync().GetAwaiter().GetResult(); } - public async Task RemoveRelationshipAsync() { if (Id == Client.User.Id) @@ -191,19 +174,16 @@ public void RemoveRelationship() RemoveRelationshipAsync().GetAwaiter().GetResult(); } - public string AsMessagable() { return $"<@{Id}>"; } - public override string ToString() { return $"{Username}#{"0000".Remove(4 - Discriminator.ToString().Length) + Discriminator.ToString()}"; } - public static implicit operator ulong(DiscordUser instance) { return instance.Id; diff --git a/Anarchy/REST/User/User/UserReportIdentification.cs b/Anarchy/REST/User/User/UserReportIdentification.cs index cacc81d8..9d2d63d9 100644 --- a/Anarchy/REST/User/User/UserReportIdentification.cs +++ b/Anarchy/REST/User/User/UserReportIdentification.cs @@ -25,7 +25,6 @@ public ulong GuildId public bool ShouldSerializeGuildId() => _guildParam.Set; - private readonly DiscordParameter _channelParam = new DiscordParameter(); [JsonProperty("channel_id")] public ulong ChannelId @@ -36,7 +35,6 @@ public ulong ChannelId public bool ShouldSerializeChannelId() => _channelParam.Set; - private readonly DiscordParameter _messageParam = new DiscordParameter(); [JsonProperty("message_id")] public ulong MessageId diff --git a/Anarchy/REST/Voice/Extensions.cs b/Anarchy/REST/Voice/Extensions.cs index 47e6d797..8e33f3de 100644 --- a/Anarchy/REST/Voice/Extensions.cs +++ b/Anarchy/REST/Voice/Extensions.cs @@ -22,7 +22,6 @@ public static void Ring(this DiscordClient client, ulong channelId, List client.RingAsync(channelId, recipients).GetAwaiter().GetResult(); } - public static async Task StartCallAsync(this DiscordClient client, ulong channelId) { await client.RingAsync(channelId, null); @@ -36,7 +35,6 @@ public static void StartCall(this DiscordClient client, ulong channelId) client.StartCallAsync(channelId).GetAwaiter().GetResult(); } - public static async Task StopRingingAsync(this DiscordClient client, ulong channelId, List recipients) { await client.HttpClient.PostAsync($"/channels/{channelId}/call/stop-ringing", new JObject @@ -53,7 +51,6 @@ public static void StopRinging(this DiscordClient client, ulong channelId, List< client.StopRingingAsync(channelId, recipients).GetAwaiter().GetResult(); } - public static async Task DeclineCallAsync(this DiscordClient client, ulong channelId) { await client.StopRingingAsync(channelId, null); @@ -67,7 +64,6 @@ public static void DeclineCall(this DiscordClient client, ulong channelId) client.DeclineCallAsync(channelId).GetAwaiter().GetResult(); } - public static async Task> GetVoiceRegionsAsync(this DiscordClient client) { return (await client.HttpClient.GetAsync("/voice/regions")) diff --git a/Anarchy/REST/Voice/VoiceRegion.cs b/Anarchy/REST/Voice/VoiceRegion.cs index af901043..e9b2287c 100644 --- a/Anarchy/REST/Voice/VoiceRegion.cs +++ b/Anarchy/REST/Voice/VoiceRegion.cs @@ -7,32 +7,26 @@ public class VoiceRegion [JsonProperty("id")] public string Id { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } [JsonProperty("optimal")] public bool Optimal { get; private set; } - [JsonProperty("vip")] public bool Premium { get; private set; } - [JsonProperty("custom")] public bool Custom { get; private set; } - [JsonProperty("deprecated")] public bool Depcrecated { get; private set; } - public override string ToString() { return Name; } - public static implicit operator string(VoiceRegion instance) { return instance.Id; diff --git a/Anarchy/WebSockets/DiscordWebSocket.cs b/Anarchy/WebSockets/DiscordWebSocket.cs index f1886e56..9e3e2af5 100644 --- a/Anarchy/WebSockets/DiscordWebSocket.cs +++ b/Anarchy/WebSockets/DiscordWebSocket.cs @@ -291,10 +291,10 @@ internal async Task ReceiverLoopAsync() } /// - /// Creates a new instance of . + /// Creates a new instance of . /// /// Proxy to use for this client instance. - /// An instance of . + /// An instance of . public static IWebSocketClient CreateNew(string url, IWebProxy proxy = null) => new DiscordWebSocket(url, proxy); } diff --git a/Anarchy/WebSockets/DiscordWebSocketMessage.cs b/Anarchy/WebSockets/DiscordWebSocketMessage.cs index 65e563bc..a9dcd301 100644 --- a/Anarchy/WebSockets/DiscordWebSocketMessage.cs +++ b/Anarchy/WebSockets/DiscordWebSocketMessage.cs @@ -10,7 +10,6 @@ public class DiscordWebSocketMessage : DiscordWebSocketRequest GetChannelAsync(this DiscordSocketClien throw new DiscordHttpException(new DiscordHttpError(DiscordError.UnknownChannel, "Channel was not found in cache")); } else - return await ((DiscordClient)client).GetChannelAsync(channelId); + return await ((DiscordClient) client).GetChannelAsync(channelId); } /// @@ -48,13 +48,12 @@ public static DiscordChannel GetChannel(this DiscordSocketClient client, ulong c return client.GetChannelAsync(channelId).GetAwaiter().GetResult(); } - public static async Task> GetGuildChannelsAsync(this DiscordSocketClient client, ulong guildId) { if (client.Config.Cache) return client.GetCachedGuild(guildId).Channels; else - return await ((DiscordClient)client).GetGuildChannelsAsync(guildId); + return await ((DiscordClient) client).GetGuildChannelsAsync(guildId); } /// @@ -66,10 +65,9 @@ public static IReadOnlyList GetGuildChannels(this DiscordSocketCli return client.GetGuildChannelsAsync(guildId).GetAwaiter().GetResult(); } - public static async Task> GetChannelMessagesAsync(this DiscordSocketClient client, ulong channelId, MessageFilters filters = null) { - var messages = await ((DiscordClient)client).GetChannelMessagesAsync(channelId, filters); + var messages = await ((DiscordClient) client).GetChannelMessagesAsync(channelId, filters); if (client.Config.Cache) { @@ -77,7 +75,7 @@ public static async Task> GetChannelMessagesAsync( if (channel.InGuild) { - GuildChannel guildChannel = (GuildChannel)channel; + GuildChannel guildChannel = (GuildChannel) channel; foreach (var message in messages) message.GuildId = guildChannel.GuildId; @@ -98,7 +96,6 @@ public static IReadOnlyList GetChannelMessages(this DiscordSocke return client.GetChannelMessagesAsync(channelId, filters).GetAwaiter().GetResult(); } - public static async Task> GetChannelMessagesAsync(this DiscordSocketClient client, ulong channelId, uint limit) { return await client.GetChannelMessagesAsync(channelId, new MessageFilters() { Limit = limit }); @@ -131,7 +128,7 @@ public static PrivateChannel CreateDM(this DiscordSocketClient client, ulong rec } } - return ((DiscordClient)client).CreateDM(recipientId); + return ((DiscordClient) client).CreateDM(recipientId); } } } diff --git a/Anarchy/WebSockets/Gateway/Channel/Private/ChannelRecipientEventArgs.cs b/Anarchy/WebSockets/Gateway/Channel/Private/ChannelRecipientEventArgs.cs index 83ea06da..e6eea3ff 100644 --- a/Anarchy/WebSockets/Gateway/Channel/Private/ChannelRecipientEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Channel/Private/ChannelRecipientEventArgs.cs @@ -12,7 +12,6 @@ public ChannelRecipientEventArgs() [JsonProperty("user")] public DiscordUser User { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; diff --git a/Anarchy/WebSockets/Gateway/Channel/Private/DiscordCall.cs b/Anarchy/WebSockets/Gateway/Channel/Private/DiscordCall.cs index fc2e103e..636687f4 100644 --- a/Anarchy/WebSockets/Gateway/Channel/Private/DiscordCall.cs +++ b/Anarchy/WebSockets/Gateway/Channel/Private/DiscordCall.cs @@ -13,15 +13,12 @@ public MinimalTextChannel Channel get { return new MinimalTextChannel(_channelId).SetClient(Client); } } - [JsonProperty("message_id")] public ulong MessageId { get; private set; } - [JsonProperty("region")] public string Region { get; private set; } - [JsonProperty("ringing")] public IReadOnlyList Ringing { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Channel/Private/GatewayPrivateChannelExtensions.cs b/Anarchy/WebSockets/Gateway/Channel/Private/GatewayPrivateChannelExtensions.cs index 8f6825ca..1b327a55 100644 --- a/Anarchy/WebSockets/Gateway/Channel/Private/GatewayPrivateChannelExtensions.cs +++ b/Anarchy/WebSockets/Gateway/Channel/Private/GatewayPrivateChannelExtensions.cs @@ -12,7 +12,7 @@ public static IReadOnlyList GetPrivateChannels(this DiscordSocke if (client.Config.Cache) return client.PrivateChannels; else - return ((DiscordClient)client).GetPrivateChannels(); + return ((DiscordClient) client).GetPrivateChannels(); } } } diff --git a/Anarchy/WebSockets/Gateway/DiscordSocketClient.cs b/Anarchy/WebSockets/Gateway/DiscordSocketClient.cs index 5681b43f..f43afba6 100644 --- a/Anarchy/WebSockets/Gateway/DiscordSocketClient.cs +++ b/Anarchy/WebSockets/Gateway/DiscordSocketClient.cs @@ -130,7 +130,6 @@ public class DiscordSocketClient : DiscordClient, IDisposable private ulong _appId; - public DiscordSocketClient(DiscordSocketConfig config = null) : base() { RequestLock = new object(); @@ -165,7 +164,7 @@ public DiscordSocketClient(DiscordSocketConfig config = null) : base() if (lostConnection) Thread.Sleep(200); - GatewayCloseCode err = (GatewayCloseCode)args.Code; + GatewayCloseCode err = (GatewayCloseCode) args.Code; if (LoggedIn && (lostConnection || err == GatewayCloseCode.RateLimited || err == GatewayCloseCode.SessionTimedOut || err == GatewayCloseCode.UnknownError)) { @@ -202,7 +201,6 @@ public DiscordSocketClient(DiscordSocketConfig config = null) : base() Dispose(true); } - public void Login(string token) { if (Token != token) @@ -216,7 +214,6 @@ public void Login(string token) WebSocket.ConnectAsync().GetAwaiter().GetResult(); } - public void Send(GatewayOpcode op, T requestData) { lock (RequestLock) @@ -230,7 +227,6 @@ public void Send(GatewayOpcode op, T requestData) } } - private void ApplyGuild(SocketGuild guild) { if (!guild.Unavailable) @@ -252,7 +248,6 @@ private void ApplyGuild(SocketGuild guild) } } - internal void TriggerVCConnect(DiscordVoiceClient client) { if (OnJoinedVoiceChannel != null) @@ -271,7 +266,6 @@ internal void TriggerVCSpeaking(DiscordVoiceClient client, IncomingVoiceStream s Task.Run(() => OnUserSpeaking.Invoke(this, new VoiceChannelSpeakingEventArgs(client, stream))); } - private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage message) { Sequence = message.Sequence; @@ -305,7 +299,7 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< foreach (var guild in login.Guilds) { - ApplyGuild(GuildCache[guild.Id] = (SocketGuild)guild); + ApplyGuild(GuildCache[guild.Id] = (SocketGuild) guild); VoiceClients[guild.Id] = new DiscordVoiceClient(this, guild.Id); } @@ -325,7 +319,7 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< Task.Run(() => OnLoggedIn.Invoke(this, login)); break; case "USER_SETTINGS_UPDATE": - UserSettings.Update((JObject)message.Data); + UserSettings.Update((JObject) message.Data); if (OnSettingsUpdated != null) Task.Run(() => OnSettingsUpdated.Invoke(this, new DiscordSettingsEventArgs(UserSettings))); @@ -474,7 +468,7 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< if (OnGiftUpdated != null) { var gift = message.Data.ToObject().SetClient(this); - gift.Json = (JObject)message.Data; + gift.Json = (JObject) message.Data; Task.Run(() => OnGiftUpdated.Invoke(this, gift)); } @@ -596,15 +590,15 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< case "CHANNEL_CREATE": if (Config.Cache || OnChannelCreated != null) { - var channel = ((JObject)message.Data).ParseDeterministic(); + var channel = ((JObject) message.Data).ParseDeterministic(); if (Config.Cache) { if (channel.Type == ChannelType.DM || channel.Type == ChannelType.Group) - PrivateChannels.Add((PrivateChannel)channel); + PrivateChannels.Add((PrivateChannel) channel); else { - GuildChannel guildChannel = (GuildChannel)channel; + GuildChannel guildChannel = (GuildChannel) channel; GuildCache[guildChannel.GuildId].ChannelsConcurrent.Add(guildChannel); } @@ -617,15 +611,15 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< case "CHANNEL_UPDATE": if (Config.Cache || OnChannelUpdated != null) { - var channel = ((JObject)message.Data).ParseDeterministic(); + var channel = ((JObject) message.Data).ParseDeterministic(); if (Config.Cache) { if (channel.Type == ChannelType.DM || channel.Type == ChannelType.Group) - PrivateChannels.ReplaceFirst(c => c.Id == channel.Id, (PrivateChannel)channel); + PrivateChannels.ReplaceFirst(c => c.Id == channel.Id, (PrivateChannel) channel); else { - GuildChannel guildChannel = (GuildChannel)channel; + GuildChannel guildChannel = (GuildChannel) channel; GuildCache[guildChannel.GuildId].ChannelsConcurrent.ReplaceFirst(c => c.Id == guildChannel.Id, guildChannel); } } @@ -637,14 +631,14 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< case "CHANNEL_DELETE": if (Config.Cache || OnChannelDeleted != null) { - var channel = ((JObject)message.Data).ParseDeterministic(); + var channel = ((JObject) message.Data).ParseDeterministic(); if (Config.Cache) { if (channel.Type == ChannelType.DM || channel.Type == ChannelType.Group) PrivateChannels.RemoveFirst(c => c.Id == channel.Id); else - GuildCache[((GuildChannel)channel).GuildId].ChannelsConcurrent.RemoveFirst(c => c.Id == channel.Id); + GuildCache[((GuildChannel) channel).GuildId].ChannelsConcurrent.RemoveFirst(c => c.Id == channel.Id); } if (OnChannelDeleted != null) @@ -719,7 +713,7 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< var recipUpdate = message.Data.ToObject().SetClient(this); if (Config.Cache) - ((PrivateChannel)this.GetChannel(recipUpdate.Channel.Id))._recipients.Add(recipUpdate.User); + ((PrivateChannel) this.GetChannel(recipUpdate.Channel.Id))._recipients.Add(recipUpdate.User); if (OnChannelRecipientAdded != null) Task.Run(() => OnChannelRecipientAdded.Invoke(this, recipUpdate)); @@ -731,7 +725,7 @@ private void WebSocket_OnMessageReceived(object sender, DiscordWebSocketMessage< var recipUpdate = message.Data.ToObject().SetClient(this); if (Config.Cache) - ((PrivateChannel)this.GetChannel(recipUpdate.Channel.Id))._recipients.RemoveFirst(u => u.Id == recipUpdate.User.Id); + ((PrivateChannel) this.GetChannel(recipUpdate.Channel.Id))._recipients.RemoveFirst(u => u.Id == recipUpdate.User.Id); if (OnChannelRecipientRemoved != null) Task.Run(() => OnChannelRecipientRemoved.Invoke(this, recipUpdate)); @@ -967,28 +961,24 @@ public void Logout() { LoggedIn = false; - WebSocket.DisconnectAsync((int)GatewayCloseCode.ClosedByClient, "Closed by client").GetAwaiter().GetResult(); + WebSocket.DisconnectAsync((int) GatewayCloseCode.ClosedByClient, "Closed by client").GetAwaiter().GetResult(); } } - public void CreateCommandHandler(string prefix) { CommandHandler = new CommandHandler(prefix, this); } - public void RegisterSlashCommands(ulong? guildId = null) { if (!LoggedIn) throw new InvalidOperationException("You must be logged in to register slash commands"); if (SlashCommandHandler == null || SlashCommandHandler.ApplicationId != _appId) SlashCommandHandler = new SlashCommandHandler(this, _appId, guildId); } - public DiscordVoiceClient GetVoiceClient(ulong guildId) => VoiceClients[guildId]; public DiscordVoiceClient GetPrivateVoiceClient() => VoiceClients.Private; - private void Reset() { SessionId = null; @@ -1016,7 +1006,6 @@ internal void Dispose(bool destructor) } } - public void Dispose() { Dispose(false); diff --git a/Anarchy/WebSockets/Gateway/Emojis/GatewayEmojiExtensions.cs b/Anarchy/WebSockets/Gateway/Emojis/GatewayEmojiExtensions.cs index af32424e..218f8e31 100644 --- a/Anarchy/WebSockets/Gateway/Emojis/GatewayEmojiExtensions.cs +++ b/Anarchy/WebSockets/Gateway/Emojis/GatewayEmojiExtensions.cs @@ -12,7 +12,7 @@ public static async Task> GetGuildEmojisAsync(this D if (client.Config.Cache) return client.GetCachedGuild(guildId).Emojis; else - return await ((DiscordClient)client).GetGuildEmojisAsync(guildId); + return await ((DiscordClient) client).GetGuildEmojisAsync(guildId); } /// @@ -24,7 +24,6 @@ public static IReadOnlyList GetGuildEmojis(this DiscordSocketClien return client.GetGuildEmojisAsync(guildId).GetAwaiter().GetResult(); } - public static async Task GetGuildEmojiAsync(this DiscordSocketClient client, ulong guildId, ulong emojiId) { if (client.Config.Cache) @@ -39,7 +38,7 @@ public static async Task GetGuildEmojiAsync(this DiscordSocketClie } } else - return await ((DiscordClient)client).GetGuildEmojiAsync(guildId, emojiId); + return await ((DiscordClient) client).GetGuildEmojiAsync(guildId, emojiId); } public static DiscordEmoji GetGuildEmoji(this DiscordSocketClient client, ulong guildId, ulong emojiId) @@ -47,7 +46,6 @@ public static DiscordEmoji GetGuildEmoji(this DiscordSocketClient client, ulong return client.GetGuildEmojiAsync(guildId, emojiId).GetAwaiter().GetResult(); } - public static DiscordEmoji GetGuildEmoji(this DiscordSocketClient client, ulong emojiId) { if (!client.Config.Cache) diff --git a/Anarchy/WebSockets/Gateway/General/LogoutEventArgs.cs b/Anarchy/WebSockets/Gateway/General/LogoutEventArgs.cs index 83a3054b..654e507b 100644 --- a/Anarchy/WebSockets/Gateway/General/LogoutEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/General/LogoutEventArgs.cs @@ -4,7 +4,7 @@ namespace Discord.Gateway { public class LogoutEventArgs : DiscordWebSocketCloseEventArgs { - public LogoutEventArgs(GatewayCloseCode error, string reason) : base((int)error, reason) + public LogoutEventArgs(GatewayCloseCode error, string reason) : base((int) error, reason) { } } } diff --git a/Anarchy/WebSockets/Gateway/Gifts/DiscordEntitlement.cs b/Anarchy/WebSockets/Gateway/Gifts/DiscordEntitlement.cs index a2abe8b4..318ce510 100644 --- a/Anarchy/WebSockets/Gateway/Gifts/DiscordEntitlement.cs +++ b/Anarchy/WebSockets/Gateway/Gifts/DiscordEntitlement.cs @@ -10,38 +10,30 @@ public class DiscordEntitlement [JsonProperty("type")] public int Type { get; private set; } // missing research - [JsonProperty("subscription_plan")] public SubscriptionPlan SubscriptionPlan { get; private set; } - [JsonProperty("sku_id")] public ulong SkuId { get; private set; } - // not entirely sure what this is, but my guess is that since // some gifts can be claimed multiple times, this might be the gift's ID [JsonProperty("parent_id")] public ulong? ParentId { get; private set; } - [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("gifter_user_id")] public ulong GifterId { get; private set; } - // not sure how they would need their own flag, but sure discord, whatever... [JsonProperty("deleted")] public bool Deleted { get; private set; } - [JsonProperty("consumed")] public bool Consumed { get; private set; } - [JsonProperty("application_id")] public ulong ApplicationId { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Gifts/GiftCodeCreatedEventArgs.cs b/Anarchy/WebSockets/Gateway/Gifts/GiftCodeCreatedEventArgs.cs index aec37781..7bf75790 100644 --- a/Anarchy/WebSockets/Gateway/Gifts/GiftCodeCreatedEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Gifts/GiftCodeCreatedEventArgs.cs @@ -7,7 +7,6 @@ public class GiftCodeCreatedEventArgs : Controllable [JsonProperty("sku_id")] public ulong SkuId { get; private set; } - [JsonProperty("code")] public string Code { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Gifts/GiftCodeUpdatedEventArgs.cs b/Anarchy/WebSockets/Gateway/Gifts/GiftCodeUpdatedEventArgs.cs index 75c4be84..8b974478 100644 --- a/Anarchy/WebSockets/Gateway/Gifts/GiftCodeUpdatedEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Gifts/GiftCodeUpdatedEventArgs.cs @@ -7,11 +7,9 @@ public class GiftCodeUpdatedEventArgs : GiftCodeCreatedEventArgs { public JObject Json { get; internal set; } - [JsonProperty("uses")] public uint Uses { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; @@ -20,7 +18,6 @@ public MinimalTextChannel Channel get { return new MinimalTextChannel(_channelId).SetClient(Client); } } - [JsonProperty("guild_id")] private readonly ulong _guildId; diff --git a/Anarchy/WebSockets/Gateway/Guild/Extensions.cs b/Anarchy/WebSockets/Gateway/Guild/Extensions.cs index f8d5b089..3455832c 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Extensions.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Extensions.cs @@ -16,7 +16,6 @@ public static IReadOnlyList GetCachedGuilds(this DiscordSocketClien return client.GuildCache.Values.ToList(); } - public static SocketGuild GetCachedGuild(this DiscordSocketClient client, ulong guildId) { if (!client.Config.Cache) @@ -32,7 +31,6 @@ public static SocketGuild GetCachedGuild(this DiscordSocketClient client, ulong } } - public static ClientGuildSettings GetGuildSettings(this DiscordSocketClient client, ulong guildId) { client.GetCachedGuild(guildId); @@ -47,7 +45,6 @@ public static ClientGuildSettings GetGuildSettings(this DiscordSocketClient clie } } - public static DiscordChannelSettings GetChannelSettings(this DiscordSocketClient client, ulong channelId) { foreach (var settings in client.PrivateChannelSettings) @@ -68,7 +65,6 @@ public static DiscordChannelSettings GetChannelSettings(this DiscordSocketClient return null; } - public static Task> GetGuildMembersAsync(this DiscordSocketClient client, ulong guildId, uint limit = 0) { List members = new List(); @@ -101,14 +97,12 @@ public static IReadOnlyList GetGuildMembers(this DiscordSocketClien return client.GetGuildMembersAsync(guildId, limit).GetAwaiter().GetResult(); } - private static void SetGuildSubscriptions(this DiscordSocketClient client, ulong guildId, GuildSubscriptionProperties properties) { properties.GuildId = guildId; client.Send(GatewayOpcode.GuildSubscriptions, properties); } - private static int[][] CreateChunks(int from, bool more) { int[][] results = new int[more ? 3 : 1][]; @@ -127,10 +121,8 @@ private static int[][] CreateChunks(int from, bool more) return results; } - public static void SubscribeToGuildEvents(this DiscordSocketClient client, ulong guildId) => SetGuildSubscriptions(client, guildId, new GuildSubscriptionProperties() { Typing = true, Activities = true, Threads = true }); - public static Task> GetGuildChannelMembersAsync(this DiscordSocketClient client, ulong guildId, ulong channelId, uint limit = 0) { var completionSource = new TaskCompletionSource>(); @@ -175,7 +167,7 @@ void handler(DiscordSocketClient s, DiscordMemberListUpdate e) { client.OnMemberListUpdate -= handler; client.OnLoggedIn -= loginHandler; - completionSource.SetResult(limit > 0 ? members.Take((int)limit).ToList() : members); + completionSource.SetResult(limit > 0 ? members.Take((int) limit).ToList() : members); break; } else if (i == 0) diff --git a/Anarchy/WebSockets/Gateway/Guild/Member/BanUpdateEventArgs.cs b/Anarchy/WebSockets/Gateway/Guild/Member/BanUpdateEventArgs.cs index 661bdd75..733eee73 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Member/BanUpdateEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Member/BanUpdateEventArgs.cs @@ -23,11 +23,9 @@ public MinimalGuild Guild } } - [JsonProperty("user")] public DiscordUser User { get; private set; } - public override string ToString() { return User.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberList.cs b/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberList.cs index 4034e85a..a18f66c1 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberList.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberList.cs @@ -10,7 +10,6 @@ public GuildMemberList() OnClientUpdated += (sender, e) => Members.SetClientsInList(Client); } - private ulong _guildId; [JsonProperty("guild_id")] public ulong GuildId @@ -24,15 +23,12 @@ public ulong GuildId } } - [JsonProperty("members")] public IReadOnlyList Members { get; private set; } - [JsonProperty("chunk_index")] public int ChunkIndex { get; private set; } - [JsonProperty("chunk_count")] public int ChunkCount { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberQuery.cs b/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberQuery.cs index 5f6e9556..7da06ecd 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberQuery.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Member/Query/GuildMemberQuery.cs @@ -10,11 +10,9 @@ public class GuildMemberQuery [JsonProperty("guild_id")] public ulong GuildId { get; set; } - [JsonProperty("query")] private readonly string _query = ""; - [JsonProperty("limit")] public uint Limit { get; set; } diff --git a/Anarchy/WebSockets/Gateway/Guild/Models/GuildEventArgs.cs b/Anarchy/WebSockets/Gateway/Guild/Models/GuildEventArgs.cs index 450a6341..8bf156fb 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Models/GuildEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Models/GuildEventArgs.cs @@ -9,7 +9,6 @@ internal GuildEventArgs(DiscordGuild guild) Guild = guild; } - public override string ToString() { return Guild.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Guild/Models/SocketGuild.cs b/Anarchy/WebSockets/Gateway/Guild/Models/SocketGuild.cs index dbe990c9..ad83bd6c 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Models/SocketGuild.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Models/SocketGuild.cs @@ -39,15 +39,12 @@ public SocketGuild() }; } - [JsonProperty("large")] public bool Large { get; private set; } - [JsonProperty("member_count")] public uint MemberCount { get; internal set; } - // i'm not 100% sure of how this functions yet. All i have so far is https://discord.com/developers/docs/topics/gateway#request-guild-members, but it doesn't seem like that applies to users. [JsonProperty("members")] internal List Members { get; private set; } @@ -58,14 +55,13 @@ public GuildMember ClientMember { GuildMember member; - while (!((DiscordSocketClient)Client).ClientMembers.TryGetValue(Id, out member)) + while (!((DiscordSocketClient) Client).ClientMembers.TryGetValue(Id, out member)) Thread.Sleep(100); return member; } } - [JsonProperty("channels")] [JsonConverter(typeof(DeepJsonConverter))] internal ConcurrentList ChannelsConcurrent; @@ -84,11 +80,9 @@ public IReadOnlyList Channels [JsonProperty("threads")] public IReadOnlyList Threads { get; internal set; } - [JsonProperty("presences")] public IReadOnlyList Presences { get; private set; } - [JsonProperty("voice_states")] internal ConcurrentList _voiceStates; @@ -103,14 +97,12 @@ public IReadOnlyList VoiceStates } } - - public Task> GetMembersAsync(uint limit = 0) => ((DiscordSocketClient)Client).GetGuildMembersAsync(Id, limit); + public Task> GetMembersAsync(uint limit = 0) => ((DiscordSocketClient) Client).GetGuildMembersAsync(Id, limit); public IReadOnlyList GetMembers(uint limit = 0) => GetMembersAsync(limit).GetAwaiter().GetResult(); - public Task> GetChannelMembersAsync(ulong channelId, uint limit = 0) => ((DiscordSocketClient)Client).GetGuildChannelMembersAsync(Id, channelId, limit); + public Task> GetChannelMembersAsync(ulong channelId, uint limit = 0) => ((DiscordSocketClient) Client).GetGuildChannelMembersAsync(Id, channelId, limit); public IReadOnlyList GetChannelMembers(ulong channelId, uint limit = 0) => GetChannelMembersAsync(channelId, limit).GetAwaiter().GetResult(); - public new void Dispose() { base.Dispose(); diff --git a/Anarchy/WebSockets/Gateway/Guild/Models/UnavailableGuild.cs b/Anarchy/WebSockets/Gateway/Guild/Models/UnavailableGuild.cs index 300dbc78..7a481d4a 100644 --- a/Anarchy/WebSockets/Gateway/Guild/Models/UnavailableGuild.cs +++ b/Anarchy/WebSockets/Gateway/Guild/Models/UnavailableGuild.cs @@ -7,11 +7,9 @@ public class UnavailableGuild [JsonProperty("id")] public ulong Id { get; private set; } - [JsonProperty("unavailable")] public bool Unavailable { get; private set; } - public bool Removed { get { return !Unavailable; } diff --git a/Anarchy/WebSockets/Gateway/Interaction/DiscordInteraction.cs b/Anarchy/WebSockets/Gateway/Interaction/DiscordInteraction.cs index 1ecf251f..f2ff9e42 100644 --- a/Anarchy/WebSockets/Gateway/Interaction/DiscordInteraction.cs +++ b/Anarchy/WebSockets/Gateway/Interaction/DiscordInteraction.cs @@ -27,7 +27,6 @@ public DiscordInteraction() } } - if (Member != null) { User = Member.User; diff --git a/Anarchy/WebSockets/Gateway/Interaction/Forms/ComponentFormButton.cs b/Anarchy/WebSockets/Gateway/Interaction/Forms/ComponentFormButton.cs index 43e3d72b..36a1a480 100644 --- a/Anarchy/WebSockets/Gateway/Interaction/Forms/ComponentFormButton.cs +++ b/Anarchy/WebSockets/Gateway/Interaction/Forms/ComponentFormButton.cs @@ -25,7 +25,6 @@ public ComponentFormButton(MessageButtonStyle style, PartialEmoji emoji) public string RedirectUrl { get; set; } public bool Disabled { get; set; } - internal override void Handle(DiscordSocketClient client, DiscordInteraction interaction) { if (OnClick != null) diff --git a/Anarchy/WebSockets/Gateway/Interaction/Forms/DiscordComponentForm.cs b/Anarchy/WebSockets/Gateway/Interaction/Forms/DiscordComponentForm.cs index 90b3434e..8927d716 100644 --- a/Anarchy/WebSockets/Gateway/Interaction/Forms/DiscordComponentForm.cs +++ b/Anarchy/WebSockets/Gateway/Interaction/Forms/DiscordComponentForm.cs @@ -65,7 +65,7 @@ public static implicit operator List(DiscordComponentForm inst { if (input.GetType() == typeof(ComponentFormSelectMenu)) { - var asSelect = (ComponentFormSelectMenu)input; + var asSelect = (ComponentFormSelectMenu) input; inputs.Add(new SelectMenuComponent() { Id = $"{instance.Id}-{asSelect.Id}", @@ -78,7 +78,7 @@ public static implicit operator List(DiscordComponentForm inst } else { - var asButton = (ComponentFormButton)input; + var asButton = (ComponentFormButton) input; inputs.Add(new ButtonComponent() { diff --git a/Anarchy/WebSockets/Gateway/Invite/InviteCreatedEventArgs.cs b/Anarchy/WebSockets/Gateway/Invite/InviteCreatedEventArgs.cs index e078c125..82ad6915 100644 --- a/Anarchy/WebSockets/Gateway/Invite/InviteCreatedEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Invite/InviteCreatedEventArgs.cs @@ -8,7 +8,6 @@ public class InviteCreatedEventArgs : Controllable [JsonProperty("code")] public string Code { get; private set; } - [JsonProperty("channel_id")] private readonly ulong _channelId; @@ -17,11 +16,9 @@ public MinimalTextChannel Channel get { return new MinimalTextChannel(_channelId).SetClient(Client); } } - [JsonProperty("created_at")] public DateTime CreatedAt { get; private set; } - [JsonProperty("guild_id")] private readonly ulong? _guildId; @@ -36,19 +33,15 @@ public MinimalGuild Guild } } - [JsonProperty("inviter")] public DiscordUser Inviter { get; private set; } - [JsonProperty("max_age")] public uint MaxAge { get; private set; } - [JsonProperty("max_uses")] public uint MaxUses { get; private set; } - [JsonProperty("temporary")] public bool Temporary { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Invite/InviteDeletedEventArgs.cs b/Anarchy/WebSockets/Gateway/Invite/InviteDeletedEventArgs.cs index 9291a81e..245c54f9 100644 --- a/Anarchy/WebSockets/Gateway/Invite/InviteDeletedEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Invite/InviteDeletedEventArgs.cs @@ -7,7 +7,6 @@ public class InviteDeletedEventArgs : Controllable [JsonProperty("code")] public string Code { get; private set; } - [JsonProperty("guild_id")] private readonly ulong? _guildId; @@ -22,7 +21,6 @@ public MinimalGuild Guild } } - [JsonProperty("channel_id")] private readonly ulong _channelId; diff --git a/Anarchy/WebSockets/Gateway/Media/DiscordMediaServer.cs b/Anarchy/WebSockets/Gateway/Media/DiscordMediaServer.cs index 0f801003..6bce103e 100644 --- a/Anarchy/WebSockets/Gateway/Media/DiscordMediaServer.cs +++ b/Anarchy/WebSockets/Gateway/Media/DiscordMediaServer.cs @@ -7,11 +7,9 @@ public class DiscordMediaServer : Controllable [JsonProperty("token")] public string Token { get; private set; } - [JsonProperty("guild_id")] internal ulong? GuildId { get; set; } - public MinimalGuild Guild { get @@ -23,7 +21,6 @@ public MinimalGuild Guild } } - private string _endpoint; [JsonProperty("endpoint")] public string Endpoint @@ -36,7 +33,6 @@ public string Endpoint } } - [JsonProperty("stream_key")] internal string StreamKey { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Media/Extensions.cs b/Anarchy/WebSockets/Gateway/Media/Extensions.cs index 58d8a276..7788f5ab 100644 --- a/Anarchy/WebSockets/Gateway/Media/Extensions.cs +++ b/Anarchy/WebSockets/Gateway/Media/Extensions.cs @@ -14,7 +14,6 @@ public static void ChangeVoiceState(this DiscordSocketClient client, VoiceStateP client.Send(GatewayOpcode.VoiceStateUpdate, properties.Fill(client)); } - public static DiscordVoiceStateContainer GetVoiceStates(this DiscordSocketClient client, ulong userId) { if (!client.Config.Cache) @@ -23,7 +22,6 @@ public static DiscordVoiceStateContainer GetVoiceStates(this DiscordSocketClient return client.VoiceStates[userId, true]; } - public static IReadOnlyList GetGuildVoiceStates(this DiscordSocketClient client, ulong guildId) { if (!client.Config.Cache) @@ -32,7 +30,6 @@ public static IReadOnlyList GetGuildVoiceStates(this DiscordS return client.GetCachedGuild(guildId).VoiceStates; } - public static IReadOnlyList GetChannelVoiceStates(this DiscordSocketClient client, ulong channelId) { if (!client.Config.Cache) @@ -65,7 +62,6 @@ public static IReadOnlyList GetChannelVoiceStates(this Discor return states; } - internal static void EndGoLive(this DiscordSocketClient client, string streamKey) { client.Send(GatewayOpcode.EndGoLive, new GoLiveStreamKey() { StreamKey = streamKey }); diff --git a/Anarchy/WebSockets/Gateway/Media/Go Live/GoLiveUpdate.cs b/Anarchy/WebSockets/Gateway/Media/Go Live/GoLiveUpdate.cs index 144ebb3e..c70cb2f9 100644 --- a/Anarchy/WebSockets/Gateway/Media/Go Live/GoLiveUpdate.cs +++ b/Anarchy/WebSockets/Gateway/Media/Go Live/GoLiveUpdate.cs @@ -8,15 +8,12 @@ internal class GoLiveUpdate [JsonProperty("stream_key")] public string StreamKey { get; private set; } - [JsonProperty("region")] public string Region { get; private set; } - [JsonProperty("paused")] public bool Paused { get; private set; } - [JsonProperty("viewer_ids")] public IReadOnlyList ViewerIds { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Media/Go Live/StartStream.cs b/Anarchy/WebSockets/Gateway/Media/Go Live/StartStream.cs index 18727479..524d53ad 100644 --- a/Anarchy/WebSockets/Gateway/Media/Go Live/StartStream.cs +++ b/Anarchy/WebSockets/Gateway/Media/Go Live/StartStream.cs @@ -9,15 +9,12 @@ internal class StartStream [JsonProperty("type")] public string Type { get; set; } - [JsonProperty("guild_id")] public ulong GuildId { get; set; } - [JsonProperty("channel_id")] public ulong ChannelId { get; set; } - [JsonProperty("preferred_region")] public string PreferredRegion { get; set; } } diff --git a/Anarchy/WebSockets/Gateway/Media/Voice/DiscordVoiceState.cs b/Anarchy/WebSockets/Gateway/Media/Voice/DiscordVoiceState.cs index 51534fff..d7a93e3c 100644 --- a/Anarchy/WebSockets/Gateway/Media/Voice/DiscordVoiceState.cs +++ b/Anarchy/WebSockets/Gateway/Media/Voice/DiscordVoiceState.cs @@ -14,7 +14,6 @@ public DiscordVoiceState() }; } - [JsonProperty("channel_id")] internal ulong? ChannelId { get; set; } @@ -29,7 +28,6 @@ public MinimalChannel Channel } } - [JsonProperty("member")] private readonly GuildMember _member; @@ -45,11 +43,9 @@ public GuildMember Member } } - [JsonProperty("user_id")] public ulong UserId { get; private set; } - [JsonProperty("guild_id")] private ulong? _guildId; @@ -68,31 +64,24 @@ internal set } } - [JsonProperty("mute")] public bool Muted { get; private set; } - [JsonProperty("deaf")] public bool Deafened { get; private set; } - [JsonProperty("self_deaf")] public bool SelfDeafened { get; private set; } - [JsonProperty("self_mute")] public bool SelfMuted { get; private set; } - [JsonProperty("self_video")] public bool Video { get; private set; } - [JsonProperty("self_stream")] public bool Streaming { get; private set; } - [JsonProperty("session_id")] internal string SessionId { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceDisconnectEventArgs.cs b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceDisconnectEventArgs.cs index 565671c3..6599b22c 100644 --- a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceDisconnectEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceDisconnectEventArgs.cs @@ -18,7 +18,7 @@ internal VoiceDisconnectEventArgs(DiscordSocketClient client, ulong? guildId, ul if (guildId.HasValue) Guild = new MinimalGuild(guildId.Value).SetClient(client); Channel = new MinimalChannel(channelId).SetClient(client); - Code = (DiscordMediaCloseCode)close.Code; + Code = (DiscordMediaCloseCode) close.Code; Reason = close.Reason; } } diff --git a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateEventArgs.cs b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateEventArgs.cs index 03045d9c..505188ea 100644 --- a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateEventArgs.cs @@ -4,7 +4,6 @@ public class VoiceStateEventArgs { public DiscordVoiceState State { get; private set; } - internal VoiceStateEventArgs(DiscordVoiceState state) { State = state; diff --git a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateProperties.cs b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateProperties.cs index 757e3f3f..739f4dcb 100644 --- a/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateProperties.cs +++ b/Anarchy/WebSockets/Gateway/Media/Voice/VoiceStateProperties.cs @@ -12,7 +12,6 @@ public ulong? GuildId set { GuildProperty.Value = value; } } - internal readonly DiscordParameter ChannelProperty = new DiscordParameter(); [JsonProperty("channel_id")] public ulong? ChannelId @@ -21,7 +20,6 @@ public ulong? ChannelId set { ChannelProperty.Value = value; } } - internal readonly DiscordParameter MutedProperty = new DiscordParameter(); [JsonProperty("self_mute")] public bool Muted @@ -30,7 +28,6 @@ public bool Muted set { MutedProperty.Value = value; } } - internal readonly DiscordParameter DeafProperty = new DiscordParameter(); [JsonProperty("self_deaf")] public bool Deafened @@ -39,7 +36,6 @@ public bool Deafened set { DeafProperty.Value = value; } } - internal readonly DiscordParameter VideoProperty = new DiscordParameter(); [JsonProperty("self_video")] public bool Video @@ -76,7 +72,7 @@ internal VoiceStateProperties Fill(DiscordSocketClient client) state = states.PrivateChannelVoiceState; if (state != null && !ChannelProperty.Set) - ChannelId = state.Channel == null ? null : (ulong?)state.Channel.Id; + ChannelId = state.Channel == null ? null : (ulong?) state.Channel.Id; } else if (ChannelProperty.Set && ChannelId.HasValue) { @@ -84,7 +80,7 @@ internal VoiceStateProperties Fill(DiscordSocketClient client) if (channel.Type != ChannelType.Group && channel.Type != ChannelType.DM) { - GuildId = ((GuildChannel)channel).GuildId; + GuildId = ((GuildChannel) channel).GuildId; if (states.GuildVoiceStates.TryGetValue(GuildId.Value, out DiscordVoiceState oldState)) state = oldState; diff --git a/Anarchy/WebSockets/Gateway/Message/MessageEventArgs.cs b/Anarchy/WebSockets/Gateway/Message/MessageEventArgs.cs index 8a17fa1d..1c9d7adf 100644 --- a/Anarchy/WebSockets/Gateway/Message/MessageEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Message/MessageEventArgs.cs @@ -11,7 +11,6 @@ internal MessageEventArgs(DiscordMessage msg) Message = msg; } - public override string ToString() { return Message.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Message/ReactionEventArgs.cs b/Anarchy/WebSockets/Gateway/Message/ReactionEventArgs.cs index fc339466..3975e745 100644 --- a/Anarchy/WebSockets/Gateway/Message/ReactionEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Message/ReactionEventArgs.cs @@ -9,7 +9,6 @@ internal ReactionEventArgs(MessageReactionUpdate reaction) Reaction = reaction; } - public override string ToString() { return Reaction.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Message/UserTypingEventArgs.cs b/Anarchy/WebSockets/Gateway/Message/UserTypingEventArgs.cs index c5113411..b5d4b5db 100644 --- a/Anarchy/WebSockets/Gateway/Message/UserTypingEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Message/UserTypingEventArgs.cs @@ -6,13 +6,11 @@ public class UserTypingEventArgs : EventArgs { public UserTyping Typing { get; private set; } - internal UserTypingEventArgs(UserTyping typing) { Typing = typing; } - public override string ToString() { return Typing.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/ActivityProperties.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/ActivityProperties.cs index e18095ee..9425a012 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/ActivityProperties.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/ActivityProperties.cs @@ -7,11 +7,9 @@ public class ActivityProperties [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("type")] public ActivityType Type { get; set; } - public override string ToString() { return Type.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/GameActivityProperties.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/GameActivityProperties.cs index 6e827316..ffb0cb63 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/GameActivityProperties.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/GameActivityProperties.cs @@ -10,22 +10,18 @@ public GameActivityProperties() _timestamps = new TimestampProperties(); } - [JsonProperty("type")] public new ActivityType Type { get { return ActivityType.Game; } } - [JsonProperty("details")] public string Details { get; set; } - [JsonProperty("state")] public string State { get; set; } - [JsonProperty("timestamps")] private TimestampProperties _timestamps; diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/StreamActivityProperties.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/StreamActivityProperties.cs index 305844a6..8217051f 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/StreamActivityProperties.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/Properties/StreamActivityProperties.cs @@ -10,7 +10,6 @@ public class StreamActivityProperties : ActivityProperties get { return ActivityType.Streaming; } } - [JsonProperty("url")] public string Url { get; set; } } diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/TimestampProperties.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/TimestampProperties.cs index 8766a213..7537ad57 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/TimestampProperties.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/TimestampProperties.cs @@ -24,7 +24,6 @@ public TimeSpan Start } } - public bool ShouldSerialize_startValue() { return _startParam.Set; diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/User/CustomStatusActivity.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/User/CustomStatusActivity.cs index 6be52957..d2a46336 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/User/CustomStatusActivity.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/User/CustomStatusActivity.cs @@ -12,11 +12,9 @@ public CustomStatusActivity() [JsonProperty("state")] public string Text { get; private set; } - [JsonProperty("emoji")] public PartialEmoji Emoji { get; private set; } - public override string ToString() { return Text; diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordActivity.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordActivity.cs index 17f69d05..adf71f99 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordActivity.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordActivity.cs @@ -7,15 +7,12 @@ public class DiscordActivity : Controllable [JsonProperty("type")] public ActivityType Type { get; private set; } - [JsonProperty("id")] public string Id { get; private set; } - [JsonProperty("name")] public string Name { get; private set; } - public override string ToString() { return Name; diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordGameActivity.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordGameActivity.cs index 6bc7bc92..870d0625 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordGameActivity.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordGameActivity.cs @@ -9,7 +9,6 @@ public class DiscordGameActivity : DiscordActivity [JsonProperty("application_id")] public string ApplicationId { get; private set; } - [JsonProperty("timestamps")] private readonly JObject _obj; diff --git a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordListeningActivity.cs b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordListeningActivity.cs index d7dde3fa..3a492512 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordListeningActivity.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Activity/User/DiscordListeningActivity.cs @@ -7,11 +7,9 @@ public class DiscordListeningActivity : DiscordActivity [JsonProperty("state")] public string Authors { get; private set; } - [JsonProperty("details")] public string Song { get; private set; } - public override string ToString() { return Song; diff --git a/Anarchy/WebSockets/Gateway/Presence/Extensions.cs b/Anarchy/WebSockets/Gateway/Presence/Extensions.cs index 6de4eef0..3354675a 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Extensions.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Extensions.cs @@ -16,7 +16,6 @@ public static DiscordPresence GetPresence(this DiscordSocketClient client, ulong } } - /// /// Updates the client's presence /// @@ -25,7 +24,6 @@ public static void UpdatePresence(this DiscordSocketClient client, PresencePrope client.Send(GatewayOpcode.PresenceChange, presence); } - /// /// Changes the client's status (online, idle, dnd or invisible) /// @@ -35,7 +33,6 @@ public static void SetStatus(this DiscordSocketClient client, UserStatus status) client.UpdatePresence(new PresenceProperties() { Status = status }); } - /// /// Sets the client's activity /// diff --git a/Anarchy/WebSockets/Gateway/Presence/Presence/ActiveSessionPlatforms.cs b/Anarchy/WebSockets/Gateway/Presence/Presence/ActiveSessionPlatforms.cs index c5109a65..daa19836 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Presence/ActiveSessionPlatforms.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Presence/ActiveSessionPlatforms.cs @@ -7,11 +7,9 @@ public class ActiveSessionPlatforms [JsonProperty("desktop")] public UserStatus Desktop { get; private set; } = UserStatus.Offline; - [JsonProperty("web")] public UserStatus Website { get; private set; } = UserStatus.Offline; - [JsonProperty("mobile")] public UserStatus Mobile { get; private set; } = UserStatus.Offline; } diff --git a/Anarchy/WebSockets/Gateway/Presence/Presence/DiscordPresence.cs b/Anarchy/WebSockets/Gateway/Presence/Presence/DiscordPresence.cs index 89d491c9..a7e10b7d 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Presence/DiscordPresence.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Presence/DiscordPresence.cs @@ -15,7 +15,6 @@ public DiscordPresence() }; } - [JsonProperty("user")] private readonly JObject _user; @@ -24,7 +23,6 @@ public ulong UserId get { return _user["id"].ToObject(); } } - private readonly DiscordParameter> _activitiesParam = new DiscordParameter>(); [JsonProperty("activities")] [JsonConverter(typeof(DeepJsonConverter))] @@ -44,7 +42,6 @@ public bool ActivitiesSet get { return _activitiesParam.Set; } } - private readonly DiscordParameter _statusParam = new DiscordParameter(); [JsonProperty("status")] public UserStatus Status @@ -58,7 +55,6 @@ public bool StatusSet get { return _statusParam.Set; } } - private readonly DiscordParameter _platformsParam = new DiscordParameter(); [JsonProperty("client_status")] public ActiveSessionPlatforms ActivePlatforms @@ -72,7 +68,6 @@ public bool ActivePlatformsSet get { return _platformsParam.Set; } } - internal void Update(DiscordPresence presence) { if (presence.ActivePlatformsSet) @@ -83,7 +78,6 @@ internal void Update(DiscordPresence presence) Status = presence.Status; } - public override string ToString() { return UserId.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Presence/Presence/PresenceProperties.cs b/Anarchy/WebSockets/Gateway/Presence/Presence/PresenceProperties.cs index 5e103364..cba459b6 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Presence/PresenceProperties.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Presence/PresenceProperties.cs @@ -12,7 +12,6 @@ public UserStatus Status set { _statusParam.Value = value; } } - private DiscordParameter _activityParam = new DiscordParameter(); [JsonProperty("game")] public ActivityProperties Activity @@ -21,17 +20,14 @@ public ActivityProperties Activity set { _activityParam.Value = value; } } - [JsonProperty("since")] #pragma warning disable CS0169, IDE0051 private readonly long _since; #pragma warning restore CS0169, IDE0051 - [JsonProperty("afk")] private readonly bool _afk = true; - public override string ToString() { return Status.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Presence/Presence/UpdatedEventArgs.cs b/Anarchy/WebSockets/Gateway/Presence/Presence/UpdatedEventArgs.cs index 2fe33178..79534991 100644 --- a/Anarchy/WebSockets/Gateway/Presence/Presence/UpdatedEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Presence/Presence/UpdatedEventArgs.cs @@ -9,7 +9,6 @@ internal PresenceUpdatedEventArgs(DiscordPresence presence) Presence = presence; } - public override string ToString() { return Presence.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Role/DeletedRole.cs b/Anarchy/WebSockets/Gateway/Role/DeletedRole.cs index 2b6d9f23..8aaf2c2e 100644 --- a/Anarchy/WebSockets/Gateway/Role/DeletedRole.cs +++ b/Anarchy/WebSockets/Gateway/Role/DeletedRole.cs @@ -12,7 +12,6 @@ public MinimalGuild Guild get { return new MinimalGuild(_guildId).SetClient(Client); } } - [JsonProperty("role_id")] public ulong Id { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Role/GatewayRoleExtensions.cs b/Anarchy/WebSockets/Gateway/Role/GatewayRoleExtensions.cs index 678b4c94..ea02d56f 100644 --- a/Anarchy/WebSockets/Gateway/Role/GatewayRoleExtensions.cs +++ b/Anarchy/WebSockets/Gateway/Role/GatewayRoleExtensions.cs @@ -11,7 +11,7 @@ public static async Task> GetGuildRolesAsync(this Dis if (client.Config.Cache) return client.GetCachedGuild(guildId).Roles; else - return await ((DiscordClient)client).GetGuildRolesAsync(guildId); + return await ((DiscordClient) client).GetGuildRolesAsync(guildId); } /// @@ -23,7 +23,6 @@ public static IReadOnlyList GetGuildRoles(this DiscordSocketClient return client.GetGuildRolesAsync(guildId).GetAwaiter().GetResult(); } - public static DiscordRole GetGuildRole(this DiscordSocketClient client, ulong roleId) { if (!client.Config.Cache) diff --git a/Anarchy/WebSockets/Gateway/Role/RoleEventArgs.cs b/Anarchy/WebSockets/Gateway/Role/RoleEventArgs.cs index a2bc29d4..af2fb95a 100644 --- a/Anarchy/WebSockets/Gateway/Role/RoleEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Role/RoleEventArgs.cs @@ -9,7 +9,6 @@ internal RoleEventArgs(DiscordRole role) Role = role; } - public override string ToString() { return Role.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Role/RoleUpdate.cs b/Anarchy/WebSockets/Gateway/Role/RoleUpdate.cs index fb550eb5..4d113f29 100644 --- a/Anarchy/WebSockets/Gateway/Role/RoleUpdate.cs +++ b/Anarchy/WebSockets/Gateway/Role/RoleUpdate.cs @@ -17,11 +17,9 @@ public ulong GuildId set { Role.GuildId = _guildId = value; } } - [JsonProperty("role")] public DiscordRole Role { get; private set; } - public override string ToString() { return Role.ToString(); diff --git a/Anarchy/WebSockets/Gateway/Session/Auth/Identification.cs b/Anarchy/WebSockets/Gateway/Session/Auth/Identification.cs index dbabd100..e1131e5a 100644 --- a/Anarchy/WebSockets/Gateway/Session/Auth/Identification.cs +++ b/Anarchy/WebSockets/Gateway/Session/Auth/Identification.cs @@ -7,29 +7,23 @@ internal class GatewayIdentification [JsonProperty("token")] public string Token { get; set; } - [JsonProperty("properties")] public SuperProperties Properties { get; set; } - [JsonProperty("presence")] public PresenceProperties Presence { get; set; } - [JsonProperty("compress")] public bool Compress { get; set; } - [JsonProperty("intents")] public DiscordGatewayIntent? Intents { get; set; } - public bool ShouldSerializeIntents() { return Intents.HasValue; } - [JsonProperty("shard")] private uint[] _shard { @@ -39,13 +33,11 @@ private uint[] _shard [JsonIgnore] public DiscordShard Shard { get; set; } - public bool ShouldSerialize_shard() { return Shard != null; } - public override string ToString() { return Token; diff --git a/Anarchy/WebSockets/Gateway/Session/Auth/LoginEventArgs.cs b/Anarchy/WebSockets/Gateway/Session/Auth/LoginEventArgs.cs index 02528c14..0473ff2f 100644 --- a/Anarchy/WebSockets/Gateway/Session/Auth/LoginEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Session/Auth/LoginEventArgs.cs @@ -26,33 +26,26 @@ internal LoginEventArgs() }; } - [JsonProperty("session_id")] internal string SessionId { get; private set; } - [JsonProperty("user")] public DiscordClientUser User { get; private set; } - [JsonProperty("status")] public UserStatus Status { get; private set; } - [JsonProperty("locale")] public DiscordLanguage Language { get; private set; } - [JsonProperty("user_settings")] public DiscordUserSettings Settings { get; private set; } - [JsonProperty("guilds")] private readonly List _guilds; public IReadOnlyList Guilds { get; private set; } - [JsonProperty("private_channels")] [JsonConverter(typeof(DeepJsonConverter))] private readonly List _channels; @@ -62,33 +55,26 @@ public IReadOnlyList PrivateChannels get { return _channels; } } - [JsonProperty("relationships")] public IReadOnlyList Relationships { get; private set; } - [JsonProperty("user_guild_settings")] internal IReadOnlyList ClientGuildSettings { get; private set; } - [JsonProperty("connected_accounts")] public IReadOnlyList ConnectedAccounts { get; private set; } - [JsonProperty("presences")] public IReadOnlyList Presences { get; private set; } - [JsonProperty("application")] internal JObject Application { get; private set; } - public override string ToString() { return User.ToString(); } - public new void Dispose() { base.Dispose(); diff --git a/Anarchy/WebSockets/Gateway/Session/Auth/Resume.cs b/Anarchy/WebSockets/Gateway/Session/Auth/Resume.cs index 382b51c1..68ca7178 100644 --- a/Anarchy/WebSockets/Gateway/Session/Auth/Resume.cs +++ b/Anarchy/WebSockets/Gateway/Session/Auth/Resume.cs @@ -17,11 +17,9 @@ internal GatewayResume(DiscordSocketClient client) [JsonProperty("token")] public string Token { get; set; } - [JsonProperty("session_id")] public string SessionId { get; set; } - [JsonProperty("seq")] public uint? Sequence { get; set; } } diff --git a/Anarchy/WebSockets/Gateway/Session/DiscordSession.cs b/Anarchy/WebSockets/Gateway/Session/DiscordSession.cs index e3d24a05..ec90bece 100644 --- a/Anarchy/WebSockets/Gateway/Session/DiscordSession.cs +++ b/Anarchy/WebSockets/Gateway/Session/DiscordSession.cs @@ -8,15 +8,12 @@ public class DiscordSession [JsonProperty("status")] public UserStatus Status { get; private set; } - [JsonProperty("session_id")] public string Id { get; private set; } - [JsonProperty("client_info")] public DiscordSessionClientInfo ClientInfo { get; private set; } - [JsonProperty("activities")] public IReadOnlyList Activities { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Session/DiscordSessionClientInfo.cs b/Anarchy/WebSockets/Gateway/Session/DiscordSessionClientInfo.cs index 8254f7d2..b4a3d776 100644 --- a/Anarchy/WebSockets/Gateway/Session/DiscordSessionClientInfo.cs +++ b/Anarchy/WebSockets/Gateway/Session/DiscordSessionClientInfo.cs @@ -7,11 +7,9 @@ public class DiscordSessionClientInfo [JsonProperty("version")] public int Version { get; private set; } - [JsonProperty("os")] public string OS { get; private set; } - [JsonProperty("client")] public string ClientType { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/Session/Extensions.cs b/Anarchy/WebSockets/Gateway/Session/Extensions.cs index 30dda2a2..6a4755c2 100644 --- a/Anarchy/WebSockets/Gateway/Session/Extensions.cs +++ b/Anarchy/WebSockets/Gateway/Session/Extensions.cs @@ -16,7 +16,6 @@ internal static void LoginToGateway(this DiscordSocketClient client) }); } - internal static void Resume(this DiscordSocketClient client) { client.Send(GatewayOpcode.Resume, new GatewayResume(client)); diff --git a/Anarchy/WebSockets/Gateway/Subscriptions/NitroBoostEventArgs.cs b/Anarchy/WebSockets/Gateway/Subscriptions/NitroBoostEventArgs.cs index 53d59078..2145c5e0 100644 --- a/Anarchy/WebSockets/Gateway/Subscriptions/NitroBoostEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/Subscriptions/NitroBoostEventArgs.cs @@ -6,7 +6,6 @@ public class NitroBoostEventArgs : EventArgs { public DiscordBoostSlot Slot { get; private set; } - internal NitroBoostEventArgs(DiscordBoostSlot boost) { Slot = boost; diff --git a/Anarchy/WebSockets/Gateway/User/RelationshipEventArgs.cs b/Anarchy/WebSockets/Gateway/User/RelationshipEventArgs.cs index c6a981bf..8ab6355a 100644 --- a/Anarchy/WebSockets/Gateway/User/RelationshipEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/User/RelationshipEventArgs.cs @@ -4,13 +4,11 @@ public class RelationshipEventArgs { public DiscordRelationship Relationship { get; private set; } - public RelationshipEventArgs(DiscordRelationship relationship) { Relationship = relationship; } - public override string ToString() { return Relationship.ToString(); diff --git a/Anarchy/WebSockets/Gateway/User/RemovedRelationshipEventArgs.cs b/Anarchy/WebSockets/Gateway/User/RemovedRelationshipEventArgs.cs index ae6bf531..94dcd570 100644 --- a/Anarchy/WebSockets/Gateway/User/RemovedRelationshipEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/User/RemovedRelationshipEventArgs.cs @@ -8,7 +8,6 @@ public class RemovedRelationshipEventArgs : EventArgs [JsonProperty("id")] public ulong UserId { get; private set; } - [JsonProperty("type")] public RelationshipType PreviousType { get; private set; } } diff --git a/Anarchy/WebSockets/Gateway/User/UserEventArgs.cs b/Anarchy/WebSockets/Gateway/User/UserEventArgs.cs index 6ba46318..082bb0a7 100644 --- a/Anarchy/WebSockets/Gateway/User/UserEventArgs.cs +++ b/Anarchy/WebSockets/Gateway/User/UserEventArgs.cs @@ -9,7 +9,6 @@ internal UserEventArgs(DiscordUser user) User = user; } - public override string ToString() { return User.ToString(); diff --git a/Anarchy/WebSockets/Gateway/User/UserStatus.cs b/Anarchy/WebSockets/Gateway/User/UserStatus.cs index e14f4da0..042d60f7 100644 --- a/Anarchy/WebSockets/Gateway/User/UserStatus.cs +++ b/Anarchy/WebSockets/Gateway/User/UserStatus.cs @@ -20,12 +20,12 @@ private UserStatus FromString(string status) else if (status == "dnd") return UserStatus.DoNotDisturb; else - return (UserStatus)Enum.Parse(typeof(UserStatus), status, true); + return (UserStatus) Enum.Parse(typeof(UserStatus), status, true); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - writer.WriteValue(ToString((UserStatus)value)); + writer.WriteValue(ToString((UserStatus) value)); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) diff --git a/Anarchy/WebSockets/Media/Codecs/MediaCodec.cs b/Anarchy/WebSockets/Media/Codecs/MediaCodec.cs index 2bda7f1e..a7d56094 100644 --- a/Anarchy/WebSockets/Media/Codecs/MediaCodec.cs +++ b/Anarchy/WebSockets/Media/Codecs/MediaCodec.cs @@ -8,7 +8,6 @@ internal class MediaCodec [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("type")] private string _type; @@ -16,7 +15,7 @@ public CodecType Type { get { - return (CodecType)Enum.Parse(typeof(CodecType), _type, true); + return (CodecType) Enum.Parse(typeof(CodecType), _type, true); } set { @@ -24,11 +23,9 @@ public CodecType Type } } - [JsonProperty("priority")] public int Priority { get; set; } = 1000; - [JsonProperty("payload_type")] public byte PayloadType { get; set; } } diff --git a/Anarchy/WebSockets/Media/Codecs/Opus/OpusDecoder.cs b/Anarchy/WebSockets/Media/Codecs/Opus/OpusDecoder.cs index 53a10246..4ca8a412 100644 --- a/Anarchy/WebSockets/Media/Codecs/Opus/OpusDecoder.cs +++ b/Anarchy/WebSockets/Media/Codecs/Opus/OpusDecoder.cs @@ -26,7 +26,7 @@ public unsafe int DecodeFrame(byte[] input, int inputOffset, int inputCount, byt fixed (byte* inPtr = input) fixed (byte* outPtr = output) result = Decode(_ptr, inPtr + inputOffset, inputCount, outPtr + outputOffset, FrameSamplesPerChannel, decodeFEC ? 1 : 0); - CheckError((OpusError)result); + CheckError((OpusError) result); return result * SampleBytes; } } diff --git a/Anarchy/WebSockets/Media/Codecs/Opus/OpusEncoder.cs b/Anarchy/WebSockets/Media/Codecs/Opus/OpusEncoder.cs index 53656cd1..37a8a836 100644 --- a/Anarchy/WebSockets/Media/Codecs/Opus/OpusEncoder.cs +++ b/Anarchy/WebSockets/Media/Codecs/Opus/OpusEncoder.cs @@ -45,12 +45,12 @@ public OpusEncoder(uint bitrate, AudioApplication application, int packetLoss) throw new ArgumentOutOfRangeException(nameof(application)); } - _ptr = CreateEncoder(SamplingRate, Channels, (int)opusApplication, out var error); + _ptr = CreateEncoder(SamplingRate, Channels, (int) opusApplication, out var error); CheckError(error); - CheckError(EncoderCtl(_ptr, OpusCtl.SetSignal, (int)opusSignal)); + CheckError(EncoderCtl(_ptr, OpusCtl.SetSignal, (int) opusSignal)); CheckError(EncoderCtl(_ptr, OpusCtl.SetPacketLossPercent, packetLoss)); //% CheckError(EncoderCtl(_ptr, OpusCtl.SetInbandFEC, 1)); //True - CheckError(EncoderCtl(_ptr, OpusCtl.SetBitrate, (int)bitrate)); + CheckError(EncoderCtl(_ptr, OpusCtl.SetBitrate, (int) bitrate)); } public unsafe int EncodeFrame(byte[] input, int inputOffset, byte[] output, int outputOffset) @@ -59,7 +59,7 @@ public unsafe int EncodeFrame(byte[] input, int inputOffset, byte[] output, int fixed (byte* inPtr = input) fixed (byte* outPtr = output) result = Encode(_ptr, inPtr + inputOffset, FrameSamplesPerChannel, outPtr + outputOffset, output.Length - outputOffset); - CheckError((OpusError)result); + CheckError((OpusError) result); return result; } } diff --git a/Anarchy/WebSockets/Media/Livestreaming/DiscordLivestreamSession.cs b/Anarchy/WebSockets/Media/Livestreaming/DiscordLivestreamSession.cs index d0321fa5..99da5e8a 100644 --- a/Anarchy/WebSockets/Media/Livestreaming/DiscordLivestreamSession.cs +++ b/Anarchy/WebSockets/Media/Livestreaming/DiscordLivestreamSession.cs @@ -16,7 +16,6 @@ public class DiscordLivestreamSession public delegate void UserDisconnectHandler(DiscordLivestreamSession session, ulong userId); public event UserDisconnectHandler OnUserDisconnected; - private readonly StreamKey _streamKey; private readonly ulong _rtcServerId; private readonly string _sessionId; diff --git a/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaIdentify.cs b/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaIdentify.cs index 52dfbf97..4671bf14 100644 --- a/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaIdentify.cs +++ b/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaIdentify.cs @@ -7,19 +7,15 @@ internal class DiscordMediaIdentify [JsonProperty("server_id")] public ulong ServerId { get; set; } - [JsonProperty("user_id")] public ulong UserId { get; set; } - [JsonProperty("session_id")] public string SessionId { get; set; } - [JsonProperty("token")] public string Token { get; set; } - [JsonProperty("video")] public bool Video { get; set; } } diff --git a/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaReady.cs b/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaReady.cs index 9f455e49..3516ecfd 100644 --- a/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaReady.cs +++ b/Anarchy/WebSockets/Media/Media/Auth/DiscordMediaReady.cs @@ -8,19 +8,15 @@ internal class DiscordMediaReady [JsonProperty("ssrc")] public uint SSRC { get; private set; } - [JsonProperty("ip")] public string IP { get; private set; } - [JsonProperty("port")] public int Port { get; private set; } - [JsonProperty("modes")] public List EncryptionModes { get; private set; } - [JsonProperty("streams")] public List Streams { get; private set; } } diff --git a/Anarchy/WebSockets/Media/Media/Auth/DiscordSessionDescription.cs b/Anarchy/WebSockets/Media/Media/Auth/DiscordSessionDescription.cs index 2cb5aff8..b6f5a8c2 100644 --- a/Anarchy/WebSockets/Media/Media/Auth/DiscordSessionDescription.cs +++ b/Anarchy/WebSockets/Media/Media/Auth/DiscordSessionDescription.cs @@ -7,11 +7,9 @@ internal class DiscordSessionDescription : MediaCodecSelection [JsonProperty("media_session_id")] public string SessionId { get; private set; } - [JsonProperty("mode")] public string EncryptionMode { get; private set; } - [JsonProperty("secret_key")] public byte[] SecretKey { get; private set; } } diff --git a/Anarchy/WebSockets/Media/Media/DiscordMediaConnection.cs b/Anarchy/WebSockets/Media/Media/DiscordMediaConnection.cs index f54dce6d..10e18843 100644 --- a/Anarchy/WebSockets/Media/Media/DiscordMediaConnection.cs +++ b/Anarchy/WebSockets/Media/Media/DiscordMediaConnection.cs @@ -70,7 +70,7 @@ private void HandleClose(object sender, DiscordWebSocketCloseEventArgs args) } else if (args.Code >= 4000) { - var discordCode = (DiscordMediaCloseCode)args.Code; + var discordCode = (DiscordMediaCloseCode) args.Code; if (discordCode == DiscordMediaCloseCode.SessionTimeout || discordCode == DiscordMediaCloseCode.ServerCrashed) { @@ -132,21 +132,18 @@ private void HandleMessage(object sender, DiscordWebSocketMessage> 0; payload[2] = 0x46 >> 8; payload[3] = 0x46 >> 0; - payload[4] = (byte)(SSRC.Audio >> 24); - payload[5] = (byte)(SSRC.Audio >> 16); - payload[6] = (byte)(SSRC.Audio >> 8); - payload[7] = (byte)(SSRC.Audio >> 0); + payload[4] = (byte) (SSRC.Audio >> 24); + payload[5] = (byte) (SSRC.Audio >> 16); + payload[6] = (byte) (SSRC.Audio >> 8); + payload[7] = (byte) (SSRC.Audio >> 0); UdpClient.Send(payload, payload.Length); } - private void SelectProtocol(IPEndPoint localEndpoint) { SendMessage(DiscordMediaOpcode.SelectProtocol, new MediaProtocolSelection() @@ -192,7 +188,6 @@ private void SelectProtocol(IPEndPoint localEndpoint) }); } - private void StartListener() { try @@ -209,7 +204,7 @@ private void StartListener() if (received[i] == 0) break; else - ip += (char)received[i]; + ip += (char) received[i]; } _localEndpoint = new IPEndPoint(IPAddress.Parse(ip), BitConverter.ToUInt16(new byte[] { received[received.Length - 1], received[received.Length - 2] }, 0)); diff --git a/Anarchy/WebSockets/Media/Media/Payloads/DiscordSSRC.cs b/Anarchy/WebSockets/Media/Media/Payloads/DiscordSSRC.cs index ddd3f7f3..747208b3 100644 --- a/Anarchy/WebSockets/Media/Media/Payloads/DiscordSSRC.cs +++ b/Anarchy/WebSockets/Media/Media/Payloads/DiscordSSRC.cs @@ -7,11 +7,9 @@ public class DiscordSSRC [JsonProperty("audio_ssrc")] public uint Audio { get; set; } - [JsonProperty("video_ssrc")] public uint Video { get; set; } - [JsonProperty("rtx_ssrc")] public uint Rtx { get; set; } } diff --git a/Anarchy/WebSockets/Media/Media/Payloads/MediaCodecSelection.cs b/Anarchy/WebSockets/Media/Media/Payloads/MediaCodecSelection.cs index 30d4e877..b584b77b 100644 --- a/Anarchy/WebSockets/Media/Media/Payloads/MediaCodecSelection.cs +++ b/Anarchy/WebSockets/Media/Media/Payloads/MediaCodecSelection.cs @@ -7,11 +7,9 @@ internal class MediaCodecSelection [JsonProperty("media_session_id")] internal string NewSessionId { get; private set; } - [JsonProperty("audio_codec")] public string AudioCodec { get; set; } - [JsonProperty("video_codec")] public string VideoCodec { get; set; } } diff --git a/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolData.cs b/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolData.cs index 34b7db4b..62c73722 100644 --- a/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolData.cs +++ b/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolData.cs @@ -7,11 +7,9 @@ internal class MediaProtocolData [JsonProperty("address")] public string Host { get; set; } - [JsonProperty("port")] public int Port { get; set; } - [JsonProperty("mode")] public string EncryptionMode { get; set; } } diff --git a/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolSelection.cs b/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolSelection.cs index d54b240a..ddc48650 100644 --- a/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolSelection.cs +++ b/Anarchy/WebSockets/Media/Media/Payloads/MediaProtocolSelection.cs @@ -8,26 +8,21 @@ internal class MediaProtocolSelection [JsonProperty("protocol")] public string Protocol { get; set; } - [JsonProperty("data")] public MediaProtocolData ProtocolData { get; set; } - [JsonProperty("rtc_connection_id")] public string RtcConnectionId { get; set; } - [JsonProperty("codecs")] public List Codecs { get; set; } - [JsonProperty("address")] public string Host { get { return ProtocolData.Host; } } - [JsonProperty("port")] public int Port { diff --git a/Anarchy/WebSockets/Media/RTP/RTPPacketHeader.cs b/Anarchy/WebSockets/Media/RTP/RTPPacketHeader.cs index 3cd3326d..c5d56c37 100644 --- a/Anarchy/WebSockets/Media/RTP/RTPPacketHeader.cs +++ b/Anarchy/WebSockets/Media/RTP/RTPPacketHeader.cs @@ -24,7 +24,7 @@ public byte Flags { get { - return HasExtensions ? (byte)0x90 : (byte)0x80; + return HasExtensions ? (byte) 0x90 : (byte) 0x80; } } @@ -65,8 +65,8 @@ public byte[] Write(byte[] secretKey, byte[] buffer, int offset, int count) if (ExtraExtensionData != null) Buffer.BlockCopy(ExtraExtensionData, 0, extensions, 0, Math.Min(ExtraExtensionData.Length, ExtensionLength / 2)); - extensions[2] = (byte)(Extensions.Count >> 8); - extensions[3] = (byte)(Extensions.Count >> 0); + extensions[2] = (byte) (Extensions.Count >> 8); + extensions[3] = (byte) (Extensions.Count >> 0); for (int i = 0; i < Extensions.Count; i++) Buffer.BlockCopy(Extensions[i], 0, extensions, (i + 1) * ExtensionLength, ExtensionLength); @@ -79,16 +79,16 @@ public byte[] Write(byte[] secretKey, byte[] buffer, int offset, int count) byte[] header = new byte[HeaderLength]; header[0] = Flags; header[1] = Type; - header[2] = (byte)(Sequence >> 8); - header[3] = (byte)(Sequence >> 0); - header[4] = (byte)(Timestamp >> 24); - header[5] = (byte)(Timestamp >> 16); - header[6] = (byte)(Timestamp >> 8); - header[7] = (byte)(Timestamp >> 0); - header[8] = (byte)(SSRC >> 24); - header[9] = (byte)(SSRC >> 16); - header[10] = (byte)(SSRC >> 8); - header[11] = (byte)(SSRC >> 0); + header[2] = (byte) (Sequence >> 8); + header[3] = (byte) (Sequence >> 0); + header[4] = (byte) (Timestamp >> 24); + header[5] = (byte) (Timestamp >> 16); + header[6] = (byte) (Timestamp >> 8); + header[7] = (byte) (Timestamp >> 0); + header[8] = (byte) (SSRC >> 24); + header[9] = (byte) (SSRC >> 16); + header[10] = (byte) (SSRC >> 8); + header[11] = (byte) (SSRC >> 0); Buffer.BlockCopy(header, 0, packet, 0, HeaderLength); Buffer.BlockCopy(extensions, 0, packet, header.Length, extensions.Length); @@ -99,7 +99,6 @@ public byte[] Write(byte[] secretKey, byte[] buffer, int offset, int count) return packet; } - public static RTPPacketHeader Read(byte[] secretKey, byte[] packet, out byte[] payload) { byte[] rawHeader = new byte[HeaderLength]; diff --git a/Anarchy/WebSockets/Media/Voice/DiscordVoiceInput.cs b/Anarchy/WebSockets/Media/Voice/DiscordVoiceInput.cs index ffabe187..ca9e2882 100644 --- a/Anarchy/WebSockets/Media/Voice/DiscordVoiceInput.cs +++ b/Anarchy/WebSockets/Media/Voice/DiscordVoiceInput.cs @@ -49,13 +49,10 @@ internal DiscordVoiceInput(DiscordVoiceClient client) _nextTick = -1; } - private List _toBeUsed = new List(); - private void UpdateEncoder() => _encoder = new OpusEncoder(_bitrate, _audioApp, _packetLoss); - public void SetSpeakingState(DiscordSpeakingFlags flags) { if (_client.State < MediaConnectionState.Ready) @@ -69,7 +66,6 @@ public void SetSpeakingState(DiscordSpeakingFlags flags) }); } - public int Write(byte[] buffer, int offset) { if (_client.State < MediaConnectionState.Ready) @@ -84,7 +80,7 @@ public int Write(byte[] buffer, int offset) long distance = _nextTick - Environment.TickCount; if (distance > 0) - Thread.Sleep((int)distance); + Thread.Sleep((int) distance); } byte[] opusFrame = new byte[OpusConverter.FrameBytes]; diff --git a/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingRequest.cs b/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingRequest.cs index 1c770a4e..49cfc400 100644 --- a/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingRequest.cs +++ b/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingRequest.cs @@ -7,11 +7,9 @@ internal class DiscordSpeakingRequest [JsonProperty("speaking")] public DiscordSpeakingFlags State { get; set; } - [JsonProperty("delay")] public int Delay { get; set; } - [JsonProperty("ssrc")] public uint SSRC { get; set; } } diff --git a/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingState.cs b/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingState.cs index 500777c4..338fd17f 100644 --- a/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingState.cs +++ b/Anarchy/WebSockets/Media/Voice/Speaking/DiscordSpeakingState.cs @@ -7,11 +7,9 @@ internal class DiscordSpeakingState [JsonProperty("user_id")] public ulong? UserId { get; internal set; } - [JsonProperty("ssrc")] public uint SSRC { get; private set; } - [JsonProperty("speaking")] public DiscordSpeakingFlags State { get; private set; } } diff --git a/Anarchy/WebSockets/Media/Voice/Speaking/IncomingVoiceStream.cs b/Anarchy/WebSockets/Media/Voice/Speaking/IncomingVoiceStream.cs index 9f16b9a1..7992dab5 100644 --- a/Anarchy/WebSockets/Media/Voice/Speaking/IncomingVoiceStream.cs +++ b/Anarchy/WebSockets/Media/Voice/Speaking/IncomingVoiceStream.cs @@ -29,7 +29,6 @@ internal IncomingVoiceStream(DiscordMediaConnection session, ulong userId) UserId = userId; } - internal void Enqueue(DiscordVoicePacket packet) { SilenceFramesReceived = 0; @@ -37,7 +36,6 @@ internal void Enqueue(DiscordVoicePacket packet) _newPacket?.Invoke(this, new EventArgs()); } - internal void Close() { if (!Closed) @@ -47,7 +45,6 @@ internal void Close() } } - public Task ReadAsync() { if (_packets.TryDequeue(out DiscordVoicePacket packet))