From d189e7a013a8ca489edac7fb2433225bb1bea65b Mon Sep 17 00:00:00 2001 From: toliner Date: Thu, 21 Dec 2017 18:02:43 +0900 Subject: [PATCH 1/2] Fixed ambiguous references --- Samurai/Components/ApiManager.cs | 8 ++++---- Samurai/Modules/TippingModule.cs | 2 +- Samurai/Samurai.csproj | 7 ++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Samurai/Components/ApiManager.cs b/Samurai/Components/ApiManager.cs index 1a222a8..d767256 100644 --- a/Samurai/Components/ApiManager.cs +++ b/Samurai/Components/ApiManager.cs @@ -12,7 +12,7 @@ public static class ApiManager { public static async Task 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)) using (var response = request.Content) { return JsonConvert.DeserializeObject(await response.ReadAsStringAsync().ConfigureAwait(false))[0]; @@ -21,7 +21,7 @@ public static async Task GetTickerAsync(string id, string convert = null public static async Task> 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)) using (var response = request.Content) { return JsonConvert.DeserializeObject[]>(await response.ReadAsStringAsync().ConfigureAwait(false))[0]; @@ -30,7 +30,7 @@ public static async Task> GetTickerAsDictionaryAsync( public static async Task 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)) using (var response = request.Content) { return JsonConvert.DeserializeObject(await response.ReadAsStringAsync().ConfigureAwait(false)); @@ -39,7 +39,7 @@ public static async Task GetTickersAsync(string convert = null) public static async Task[]> 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)) using (var response = request.Content) { return JsonConvert.DeserializeObject[]>(await response.ReadAsStringAsync().ConfigureAwait(false)); diff --git a/Samurai/Modules/TippingModule.cs b/Samurai/Modules/TippingModule.cs index 383571b..59ef1a6 100644 --- a/Samurai/Modules/TippingModule.cs +++ b/Samurai/Modules/TippingModule.cs @@ -88,7 +88,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; } var targets = await TippingManager.GetUsersAsync(Context.Channel, Context.User, 10).ConfigureAwait(false); if (targets.Any()) diff --git a/Samurai/Samurai.csproj b/Samurai/Samurai.csproj index da98ce8..89309af 100644 --- a/Samurai/Samurai.csproj +++ b/Samurai/Samurai.csproj @@ -1,5 +1,4 @@ - - + Exe netcoreapp2.0 @@ -14,11 +13,9 @@ https://raw.githubusercontent.com/acid-chicken/Samurai/master/Assets/Samurai.png https://github.com/acid-chicken/Samurai.git - - - + \ No newline at end of file From 3035db359082435cbfd5739277eda75cf2ea9ba6 Mon Sep 17 00:00:00 2001 From: toliner Date: Thu, 21 Dec 2017 18:04:36 +0900 Subject: [PATCH 2/2] Optimize imports --- Samurai/Components/ApiManager.cs | 5 +---- Samurai/Models/RpcResponse.cs | 2 -- Samurai/Models/Ticker.cs | 3 --- Samurai/Modules/CommonModule.cs | 6 ++---- Samurai/Modules/ConversionModule.cs | 7 ++----- Samurai/Modules/ModuleManager.cs | 5 ++--- Samurai/Modules/TippingModule.cs | 12 ++++-------- Samurai/Program.cs | 10 +++------- Samurai/Tasks/TickerManager.cs | 6 ++---- Samurai/Tasks/TippingManager.cs | 8 +------- 10 files changed, 17 insertions(+), 47 deletions(-) diff --git a/Samurai/Components/ApiManager.cs b/Samurai/Components/ApiManager.cs index d767256..cfa341e 100644 --- a/Samurai/Components/ApiManager.cs +++ b/Samurai/Components/ApiManager.cs @@ -1,13 +1,10 @@ -using System; using System.Collections.Generic; -using System.Net.Http; using System.Threading.Tasks; +using AcidChicken.Samurai.Models; using Newtonsoft.Json; namespace AcidChicken.Samurai.Components { - using static Program; - using Models; public static class ApiManager { public static async Task GetTickerAsync(string id, string convert = null) diff --git a/Samurai/Models/RpcResponse.cs b/Samurai/Models/RpcResponse.cs index 191fd95..f1fdd9f 100644 --- a/Samurai/Models/RpcResponse.cs +++ b/Samurai/Models/RpcResponse.cs @@ -1,6 +1,4 @@ -using System; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace AcidChicken.Samurai.Models { diff --git a/Samurai/Models/Ticker.cs b/Samurai/Models/Ticker.cs index 2f78c15..37dfefd 100644 --- a/Samurai/Models/Ticker.cs +++ b/Samurai/Models/Ticker.cs @@ -1,10 +1,7 @@ -using System; using Newtonsoft.Json; namespace AcidChicken.Samurai.Models { - using Tasks; - [JsonObject] public class Ticker { diff --git a/Samurai/Modules/CommonModule.cs b/Samurai/Modules/CommonModule.cs index 9e7f12a..99ee2aa 100644 --- a/Samurai/Modules/CommonModule.cs +++ b/Samurai/Modules/CommonModule.cs @@ -4,16 +4,14 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; +using AcidChicken.Samurai.Assets; +using AcidChicken.Samurai.Components; 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 diff --git a/Samurai/Modules/ConversionModule.cs b/Samurai/Modules/ConversionModule.cs index 1ab6673..72ac28d 100644 --- a/Samurai/Modules/ConversionModule.cs +++ b/Samurai/Modules/ConversionModule.cs @@ -1,15 +1,12 @@ -using System; using System.Linq; using System.Threading.Tasks; +using AcidChicken.Samurai.Assets; +using AcidChicken.Samurai.Components; 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 { diff --git a/Samurai/Modules/ModuleManager.cs b/Samurai/Modules/ModuleManager.cs index cbebb7b..84537cf 100644 --- a/Samurai/Modules/ModuleManager.cs +++ b/Samurai/Modules/ModuleManager.cs @@ -1,8 +1,9 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; +using AcidChicken.Samurai.Assets; +using AcidChicken.Samurai.Components; using Discord; using Discord.Commands; using Discord.WebSocket; @@ -10,8 +11,6 @@ namespace AcidChicken.Samurai.Modules { using static Program; - using Assets; - using Components; public static class ModuleManager { diff --git a/Samurai/Modules/TippingModule.cs b/Samurai/Modules/TippingModule.cs index 59ef1a6..03299ee 100644 --- a/Samurai/Modules/TippingModule.cs +++ b/Samurai/Modules/TippingModule.cs @@ -1,20 +1,16 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using AcidChicken.Samurai.Assets; +using AcidChicken.Samurai.Components; +using AcidChicken.Samurai.Models; +using AcidChicken.Samurai.Tasks; 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 diff --git a/Samurai/Program.cs b/Samurai/Program.cs index 366c555..335dfc0 100644 --- a/Samurai/Program.cs +++ b/Samurai/Program.cs @@ -1,10 +1,11 @@ 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; +using AcidChicken.Samurai.Modules; +using AcidChicken.Samurai.Tasks; using Discord; using Discord.WebSocket; using LiteDB; @@ -12,11 +13,6 @@ namespace AcidChicken.Samurai { - using Components; - using Models; - using Modules; - using Tasks; - public static class Program { public const string ConfigurePath = "config.json"; diff --git a/Samurai/Tasks/TickerManager.cs b/Samurai/Tasks/TickerManager.cs index 91ef05a..a02a329 100644 --- a/Samurai/Tasks/TickerManager.cs +++ b/Samurai/Tasks/TickerManager.cs @@ -1,15 +1,13 @@ using System; -using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using AcidChicken.Samurai.Components; +using AcidChicken.Samurai.Models; using Discord; -using Newtonsoft.Json; namespace AcidChicken.Samurai.Tasks { using static Program; - using Components; - using Models; public static class TickerManager { diff --git a/Samurai/Tasks/TippingManager.cs b/Samurai/Tasks/TippingManager.cs index f195cdd..a9c0328 100644 --- a/Samurai/Tasks/TippingManager.cs +++ b/Samurai/Tasks/TippingManager.cs @@ -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; 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 {