Use Environment rather than AppContext

master
exsersewo 5 years ago
parent 58c6c84a0b
commit 9f81cf405c
  1. 40
      Kehyeedra3/Bot.cs
  2. 10
      Kehyeedra3/Commands.cs
  3. 2
      Kehyeedra3/Configuration.cs

@ -33,23 +33,23 @@ namespace Kehyeedra3
public static ReminderService RmService;
string[] rcsounds = new string[]
{
AppContext.BaseDirectory + @"Audio\goblin_death.wav",
AppContext.BaseDirectory + @"Audio\cough1.wav",
AppContext.BaseDirectory + @"Audio\cough2.wav",
AppContext.BaseDirectory + @"Audio\wilhelmcough.wav",
AppContext.BaseDirectory + @"Audio\trapcough1.wav",
AppContext.BaseDirectory + @"Audio\trapcough2.wav",
AppContext.BaseDirectory + @"Audio\h3h3cough1.wav",
AppContext.BaseDirectory + @"Audio\h3h3cough2.wav",
AppContext.BaseDirectory + @"Audio\h3h3cough3.wav",
AppContext.BaseDirectory + @"Audio\h3h3cough4.wav",
AppContext.BaseDirectory + @"Audio\h3h3cough5.wav",
AppContext.BaseDirectory + @"Audio\sodocough.mp3",
AppContext.BaseDirectory + @"Audio\dbzscream.wav",
AppContext.BaseDirectory + @"Audio\healthycough1.wav",
AppContext.BaseDirectory + @"Audio\poohcough1.wav",
AppContext.BaseDirectory + @"Audio\jontronooh.wav",
AppContext.BaseDirectory + @"Audio\deep.wav"
Environment.CurrentDirectory + @"Audio\goblin_death.wav",
Environment.CurrentDirectory + @"Audio\cough1.wav",
Environment.CurrentDirectory + @"Audio\cough2.wav",
Environment.CurrentDirectory + @"Audio\wilhelmcough.wav",
Environment.CurrentDirectory + @"Audio\trapcough1.wav",
Environment.CurrentDirectory + @"Audio\trapcough2.wav",
Environment.CurrentDirectory + @"Audio\h3h3cough1.wav",
Environment.CurrentDirectory + @"Audio\h3h3cough2.wav",
Environment.CurrentDirectory + @"Audio\h3h3cough3.wav",
Environment.CurrentDirectory + @"Audio\h3h3cough4.wav",
Environment.CurrentDirectory + @"Audio\h3h3cough5.wav",
Environment.CurrentDirectory + @"Audio\sodocough.mp3",
Environment.CurrentDirectory + @"Audio\dbzscream.wav",
Environment.CurrentDirectory + @"Audio\healthycough1.wav",
Environment.CurrentDirectory + @"Audio\poohcough1.wav",
Environment.CurrentDirectory + @"Audio\jontronooh.wav",
Environment.CurrentDirectory + @"Audio\deep.wav"
};
public async Task CreateBot()
@ -167,7 +167,7 @@ namespace Kehyeedra3
public static void EnsureConfigExists()
{
string storage = AppDomain.CurrentDomain.BaseDirectory;
string storage = Environment.CurrentDirectory;
if (!Directory.Exists(Path.Combine(storage, "storage")))
Directory.CreateDirectory(Path.Combine(storage, "storage"));
@ -186,7 +186,7 @@ namespace Kehyeedra3
{
try
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config",
string path = Path.Combine(Environment.CurrentDirectory, "config",
"Settings.xml");
if (File.Exists(path))
{
@ -195,7 +195,7 @@ namespace Kehyeedra3
ChatService.isAcceptingUserInput = false;
ChatService.loadAIMLFromFiles();
ChatService.isAcceptingUserInput = true;
PathToUserData = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "aimlusers");
PathToUserData = Path.Combine(Environment.CurrentDirectory, "aimlusers");
Console.WriteLine("Loaded: Chat Service");
}
else { }

@ -164,7 +164,7 @@ namespace Kehyeedra3
[Command("delet")]
public async Task DeletThis()
{
string imgdirpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Delet");
string imgdirpath = Path.Combine(Environment.CurrentDirectory, "Delet");
DirectoryInfo imgdir = new DirectoryInfo(imgdirpath);
var files = imgdir.GetFiles();
var item = files[Bot._rnd.Next(0, files.Length)];
@ -174,7 +174,7 @@ namespace Kehyeedra3
[Command("delet")]
public async Task DeletThis(ITextChannel channel)
{
string imgdirpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Delet");
string imgdirpath = Path.Combine(Environment.CurrentDirectory, "Delet");
DirectoryInfo imgdir = new DirectoryInfo(imgdirpath);
var files = imgdir.GetFiles();
var item = files[Bot._rnd.Next(0, files.Length)];
@ -1171,7 +1171,7 @@ namespace Kehyeedra3
Uri link = new Uri(item.Url);
using (WebClient _webclient = new WebClient())
{
string location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "delet");
string location = Path.Combine(Environment.CurrentDirectory, "delet");
if (!Directory.Exists(location))
Directory.CreateDirectory(location);
location += "/" + item.Filename;
@ -1188,7 +1188,7 @@ namespace Kehyeedra3
Uri link = new Uri(url);
using (WebClient _webclient = new WebClient())
{
string location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"delet");
string location = Path.Combine(Environment.CurrentDirectory, $"delet");
if (!Directory.Exists(location))
Directory.CreateDirectory(location);
location += "/" + Guid.NewGuid() + ".jpg";
@ -1229,7 +1229,7 @@ namespace Kehyeedra3
public async Task SaveFile(string fday, string fscore)
{
string location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "drawtasks");
string location = Path.Combine(Environment.CurrentDirectory, "drawtasks");
string tlocation = ($"{location}/days.txt");
var attachments = Context.Message.Attachments;
string fname = $"{fday}-{fscore}";

@ -8,7 +8,7 @@ namespace Kehyeedra3
class Configuration
{
[JsonIgnore]
public static readonly string appdir = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string appdir = Environment.CurrentDirectory;
public string Prefix { get; set; }
public string Token { get; set; }
public int Shards { get; set; }

Loading…
Cancel
Save