Skip to content

Commit

Permalink
Code style adheres to .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-henning committed Sep 25, 2022
1 parent 20175df commit 0ac9311
Show file tree
Hide file tree
Showing 246 changed files with 117 additions and 1,220 deletions.
3 changes: 2 additions & 1 deletion Anarchy/Anarchy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<NoWarn>IDE1006, CS0649, CS0414, IDE0051</NoWarn>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
5 changes: 2 additions & 3 deletions Anarchy/Commands/Command/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ internal CommandHandler(string prefix, DiscordSocketClient client)
}
}


private void Client_OnMessageReceived(DiscordSocketClient client, MessageEventArgs args)
{
if (args.Message.Content.StartsWith(Prefix))
Expand All @@ -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++)
Expand Down Expand Up @@ -171,7 +170,7 @@ internal static bool TryGetAttribute<TAttr>(IEnumerable<object> attributes, out
{
if (attribute.GetType() == typeof(TAttr))
{
attr = (TAttr)attribute;
attr = (TAttr) attribute;
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Anarchy/Commands/SlashCommands/SlashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Anarchy/Commands/SlashCommands/SlashCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public SlashCommandHandler(DiscordSocketClient client, ulong appId, ulong? guild
{
if (choices == null) choices = new List<CommandOptionChoice>();

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");
Expand Down Expand Up @@ -177,7 +177,7 @@ private void Handle(string cmdName, DiscordInteraction interaction, List<SlashCo
{
var localCommand = _handlerDict[cmdName];

var handler = (SlashCommand)Activator.CreateInstance(localCommand.HandlerType);
var handler = (SlashCommand) Activator.CreateInstance(localCommand.HandlerType);
handler.Prepare(interaction);

if (arguments != null)
Expand Down Expand Up @@ -239,7 +239,7 @@ private static bool TryGetAttribute<TAttr>(IEnumerable<object> attributes, out T
{
if (attribute.GetType() == typeof(TAttr))
{
attr = (TAttr)attribute;
attr = (TAttr) attribute;
return true;
}
}
Expand Down
1 change: 0 additions & 1 deletion Anarchy/Local/Controllable/Controllable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public DiscordClient Client
}
}


public void Dispose()
{
_client = null;
Expand Down
1 change: 0 additions & 1 deletion Anarchy/Local/Controllable/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static T SetClient<T>(this T @class, DiscordClient client) where T : Cont
return @class;
}


internal static IReadOnlyList<T> SetClientsInList<T>(this IReadOnlyList<T> classes, DiscordClient client) where T : Controllable
{
if (classes != null)
Expand Down
2 changes: 1 addition & 1 deletion Anarchy/Local/Controllable/JsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static T ParseDeterministic<T>(this JObject obj)
if (TryFindTypes(typeof(T), out Dictionary<int, Type> types))
{
int type = obj.Value<int>("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");
Expand Down
2 changes: 1 addition & 1 deletion Anarchy/Local/DiscordImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Discord
{
class ImageJsonConverter : JsonConverter<DiscordImage>
internal class ImageJsonConverter : JsonConverter<DiscordImage>
{
public override bool CanRead => false;

Expand Down
2 changes: 0 additions & 2 deletions Anarchy/Local/DiscordParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public T Value
}
}


public static implicit operator T(DiscordParameter<T> instance)
{
return instance.Value;
}


public override string ToString()
{
return Value.ToString();
Expand Down
6 changes: 0 additions & 6 deletions Anarchy/REST/Billing/BillingAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Expand Down
4 changes: 0 additions & 4 deletions Anarchy/REST/Billing/CardPaymentMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Expand Down
7 changes: 0 additions & 7 deletions Anarchy/REST/Billing/DiscordPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PaymentMethod>))]
public PaymentMethod PaymentMethod { get; private set; }
Expand Down
1 change: 0 additions & 1 deletion Anarchy/REST/Billing/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static IReadOnlyList<DiscordPayment> GetPayments(this DiscordClient clien
return client.GetPaymentsAsync(limit).GetAwaiter().GetResult();
}


public static async Task<IReadOnlyList<PaymentMethod>> GetPaymentMethodsAsync(this DiscordClient client)
{
return (await client.HttpClient.GetAsync("/users/@me/billing/payment-sources"))
Expand Down
7 changes: 0 additions & 7 deletions Anarchy/REST/Billing/PaymentMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> PurchaseGiftAsync(ulong skuId, ulong subPlanId, int expectedAmount)
{
return await Client.PurchaseGiftAsync(Id, skuId, subPlanId, expectedAmount);
Expand All @@ -39,7 +33,6 @@ public string PurchaseGift(ulong skuId, ulong subPlanId, int expectedAmount)
return PurchaseGiftAsync(skuId, subPlanId, expectedAmount).GetAwaiter().GetResult();
}


public async Task<string> PurchaseNitroGiftAsync(DiscordNitroSubType nitroType)
{
return await Client.PurchaseNitroGiftAsync(Id, nitroType);
Expand Down
2 changes: 0 additions & 2 deletions Anarchy/REST/Channel/Channel/CreationProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 0 additions & 6 deletions Anarchy/REST/Channel/Channel/DiscordChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions Anarchy/REST/Channel/Channel/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static DiscordChannel GetChannel(this DiscordClient client, ulong channel
return client.GetChannelAsync(channelId).GetAwaiter().GetResult();
}


public static async Task<DiscordGroup> ModifyGroupAsync(this DiscordClient client, ulong groupId, GroupProperties properties)
{
return (await client.HttpClient.PatchAsync($"/channels/{groupId}", properties))
Expand All @@ -31,7 +30,6 @@ public static DiscordGroup ModifyGroup(this DiscordClient client, ulong groupId,
return client.ModifyGroupAsync(groupId, properties).GetAwaiter().GetResult();
}


public static async Task<GuildChannel> ModifyGuildChannelAsync(this DiscordClient client, ulong channelId, GuildChannelProperties properties)
{
return (await client.HttpClient.PatchAsync($"/channels/{channelId}", properties))
Expand All @@ -43,7 +41,6 @@ public static GuildChannel ModifyGuildChannel(this DiscordClient client, ulong c
return client.ModifyGuildChannelAsync(channelId, properties).GetAwaiter().GetResult();
}


public static async Task<DiscordChannel> DeleteChannelAsync(this DiscordClient client, ulong channelId)
{
return (await client.HttpClient.DeleteAsync($"/channels/{channelId}"))
Expand Down
8 changes: 0 additions & 8 deletions Anarchy/REST/Channel/Channel/MinimalTextChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public void TriggerTyping()
TriggerTypingAsync().GetAwaiter().GetResult();
}


public Task<DiscordMessage> SendMessageAsync(MessageProperties properties)
{
return Client.SendMessageAsync(Id, properties);
Expand Down Expand Up @@ -60,7 +59,6 @@ public DiscordMessage SendMessage(EmbedMaker embed)
return SendMessageAsync(embed).GetAwaiter().GetResult();
}


public async Task<DiscordMessage> SendFileAsync(string fileName, byte[] fileData, string message = null, bool tts = false)
{
return await Client.SendFileAsync(Id, fileName, fileData, message, tts);
Expand All @@ -71,7 +69,6 @@ public DiscordMessage SendFile(string fileName, byte[] fileData, string message
return SendFileAsync(fileName, fileData, message, tts).GetAwaiter().GetResult();
}


public async Task<DiscordMessage> SendFileAsync(string filePath, string message = null, bool tts = false)
{
return await Client.SendFileAsync(Id, filePath, message, tts);
Expand All @@ -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<ulong> messages)
{
await Client.DeleteMessagesAsync(Id, messages);
Expand All @@ -98,7 +94,6 @@ public void DeleteMessages(List<ulong> messages)
DeleteMessagesAsync(messages).GetAwaiter().GetResult();
}


public async Task<IReadOnlyList<DiscordMessage>> GetMessagesAsync(MessageFilters filters = null)
{
return await Client.GetChannelMessagesAsync(Id, filters);
Expand All @@ -113,7 +108,6 @@ public IReadOnlyList<DiscordMessage> GetMessages(MessageFilters filters = null)
return GetMessagesAsync(filters).GetAwaiter().GetResult();
}


public async Task<IReadOnlyList<DiscordMessage>> GetPinnedMessagesAsync()
{
return await Client.GetPinnedMessagesAsync(Id);
Expand All @@ -127,7 +121,6 @@ public IReadOnlyList<DiscordMessage> GetPinnedMessages()
return GetPinnedMessagesAsync().GetAwaiter().GetResult();
}


public async Task PinMessageAsync(ulong messageId)
{
await Client.PinMessageAsync(Id, messageId);
Expand All @@ -142,7 +135,6 @@ public void PinMessage(ulong messageId)
PinMessageAsync(messageId).GetAwaiter().GetResult();
}


public async Task UnpinMessageAsync(ulong messageId)
{
await Client.UnpinChannelMessageAsync(Id, messageId);
Expand Down
Loading

0 comments on commit 0ac9311

Please sign in to comment.