-
Notifications
You must be signed in to change notification settings - Fork 4
Minimum Refectoring #2
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Newtonsoft.Json; | ||
|
||
namespace AcidChicken.Samurai.Components | ||
{ | ||
using static Program; | ||
using Models; | ||
public static class ApiManager | ||
{ | ||
public static async Task<Ticker> GetTickerAsync(string id, string convert = null) | ||
{ | ||
using (var request = await HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/{id}/{(string.IsNullOrEmpty(convert) ? "" : $"?convert={convert}")}").ConfigureAwait(false)) | ||
using (var request = await Program.HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/{id}/{(string.IsNullOrEmpty(convert) ? "" : $"?convert={convert}")}").ConfigureAwait(false)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be verbose expressions. If you are feeling risks about it, please make unsafe member names safety. |
||
using (var response = request.Content) | ||
{ | ||
return JsonConvert.DeserializeObject<Ticker[]>(await response.ReadAsStringAsync().ConfigureAwait(false))[0]; | ||
|
@@ -21,7 +18,7 @@ public static async Task<Ticker> GetTickerAsync(string id, string convert = null | |
|
||
public static async Task<Dictionary<string, string>> GetTickerAsDictionaryAsync(string id, string convert = null) | ||
{ | ||
using (var request = await HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/{id}/{(string.IsNullOrEmpty(convert) ? "" : $"?convert={convert}")}").ConfigureAwait(false)) | ||
using (var request = await Program.HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/{id}/{(string.IsNullOrEmpty(convert) ? "" : $"?convert={convert}")}").ConfigureAwait(false)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be verbose expressions. If you are feeling risks about it, please make unsafe member names safety. |
||
using (var response = request.Content) | ||
{ | ||
return JsonConvert.DeserializeObject<Dictionary<string, string>[]>(await response.ReadAsStringAsync().ConfigureAwait(false))[0]; | ||
|
@@ -30,7 +27,7 @@ public static async Task<Ticker> GetTickerAsync(string id, string convert = null | |
|
||
public static async Task<Ticker[]> GetTickersAsync(string convert = null) | ||
{ | ||
using (var request = await HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/?limit=0{(string.IsNullOrEmpty(convert) ? "" : $"&convert={convert}")}").ConfigureAwait(false)) | ||
using (var request = await Program.HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/?limit=0{(string.IsNullOrEmpty(convert) ? "" : $"&convert={convert}")}").ConfigureAwait(false)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be verbose expressions. If you are feeling risks about it, please make unsafe member names safety. |
||
using (var response = request.Content) | ||
{ | ||
return JsonConvert.DeserializeObject<Ticker[]>(await response.ReadAsStringAsync().ConfigureAwait(false)); | ||
|
@@ -39,7 +36,7 @@ public static async Task<Ticker[]> GetTickersAsync(string convert = null) | |
|
||
public static async Task<Dictionary<string, string>[]> GetTickersAsDictionaryAsync(string convert = null) | ||
{ | ||
using (var request = await HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/?limit=0{(string.IsNullOrEmpty(convert) ? "" : $"&convert={convert}")}").ConfigureAwait(false)) | ||
using (var request = await Program.HttpClient.GetAsync($"https://api.coinmarketcap.com/v1/ticker/?limit=0{(string.IsNullOrEmpty(convert) ? "" : $"&convert={convert}")}").ConfigureAwait(false)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be verbose expressions. If you are feeling risks about it, please make unsafe member names safety. |
||
using (var response = request.Content) | ||
{ | ||
return JsonConvert.DeserializeObject<Dictionary<string, string>[]>(await response.ReadAsStringAsync().ConfigureAwait(false)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "System" reference instruction must be defined at the top of the code file. |
||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace AcidChicken.Samurai.Models | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
using System; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "System" reference instruction must be defined at the top of the code file. |
||
using Newtonsoft.Json; | ||
|
||
namespace AcidChicken.Samurai.Models | ||
{ | ||
using Tasks; | ||
|
||
[JsonObject] | ||
public class Ticker | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,14 @@ | |
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Assets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Discord.Commands; | ||
|
||
namespace AcidChicken.Samurai.Modules | ||
{ | ||
using static Program; | ||
using Assets; | ||
using Components; | ||
using Models; | ||
using Tasks; | ||
|
||
[Group(""), Summary("汎用モジュールです。")] | ||
public class CommonModule : ModuleBase | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
using System; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "System" reference instruction must be defined at the top of the code file. |
||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Assets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Discord.Commands; | ||
|
||
namespace AcidChicken.Samurai.Modules | ||
{ | ||
using static Program; | ||
using Assets; | ||
using Components; | ||
|
||
[Group("conversion"), Summary("通貨換算モジュールです。"), Alias("conv", "c")] | ||
public class ConversionModule : ModuleBase | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
using System; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "System" reference instruction must be defined at the top of the code file. |
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Assets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Discord.Commands; | ||
using Discord.WebSocket; | ||
|
||
namespace AcidChicken.Samurai.Modules | ||
{ | ||
using static Program; | ||
using Assets; | ||
using Components; | ||
|
||
public static class ModuleManager | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Assets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Tasks; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Discord.Commands; | ||
using Discord.Net; | ||
using LiteDB; | ||
using Newtonsoft.Json; | ||
|
||
namespace AcidChicken.Samurai.Modules | ||
{ | ||
using static Program; | ||
using Assets; | ||
using Components; | ||
using Models; | ||
using Tasks; | ||
|
||
[Group(""), Summary("投げ銭モジュールです。")] | ||
public class TippingModule : ModuleBase | ||
|
@@ -88,7 +84,7 @@ public async Task RainAsync([Summary("金額")] decimal totalAmount = decimal.Mi | |
{ | ||
if (totalAmount == decimal.MinusOne) | ||
{ | ||
totalAmount = (decimal)Math.Pow(10, Random.NextDouble()) - 1; | ||
totalAmount = (decimal)Math.Pow(10, Program.Random.NextDouble()) - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be verbose expressions. If you are feeling risks about it, please make unsafe member names safety. |
||
} | ||
var targets = await TippingManager.GetUsersAsync(Context.Channel, Context.User, 10).ConfigureAwait(false); | ||
if (targets.Any()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Modules; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Tasks; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Discord.WebSocket; | ||
using LiteDB; | ||
using Newtonsoft.Json; | ||
|
||
namespace AcidChicken.Samurai | ||
{ | ||
using Components; | ||
using Models; | ||
using Modules; | ||
using Tasks; | ||
|
||
public static class Program | ||
{ | ||
public const string ConfigurePath = "config.json"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
|
@@ -14,11 +13,9 @@ | |
<PackageIconUrl>https://raw.githubusercontent.com/acid-chicken/Samurai/master/Assets/Samurai.png</PackageIconUrl> | ||
<RepositoryUrl>https://github.com/acid-chicken/Samurai.git</RepositoryUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Net.Ping" Version="4.3.0" /> | ||
<PackageReference Include="Discord.Net" Version="1.0.2" /> | ||
<PackageReference Include="LiteDB" Version="4.1.0" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the ends of files have to be finished with a new line. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using AcidChicken.Samurai.Models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using Newtonsoft.Json; | ||
|
||
namespace AcidChicken.Samurai.Tasks | ||
{ | ||
using static Program; | ||
using Components; | ||
using Models; | ||
|
||
public static class TickerManager | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,16 @@ | |
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AcidChicken.Samurai.Models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the local namespace reference instructions have to be included in the local namespace block. |
||
using Discord; | ||
using LiteDB; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace AcidChicken.Samurai.Tasks | ||
{ | ||
using static Program; | ||
using Components; | ||
using Models; | ||
|
||
public static class TippingManager | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "System" reference instruction must be defined at the top of the code file.