This commit is contained in:
@@ -8,15 +8,26 @@ namespace EVE_LevelingSystem
|
|||||||
{
|
{
|
||||||
internal class Level : DBEvent
|
internal class Level : DBEvent
|
||||||
{
|
{
|
||||||
public string name => "Leveling System Event Handler";
|
public string name => "Leveling System Event Handler";
|
||||||
public string description => "The Leveling System Event Handler";
|
public string description => "The Leveling System Event Handler";
|
||||||
|
internal static Settings globalSettings = new();
|
||||||
|
|
||||||
|
|
||||||
public void Start(DiscordSocketClient client)
|
public async void Start(DiscordSocketClient client)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory("./Data/Resources/LevelingSystem");
|
Directory.CreateDirectory("./Data/Resources/LevelingSystem");
|
||||||
Config.AddValueToVariables("LevelingSystemPath", "./Data/Resources/LevelingSystem");
|
Config.AddValueToVariables("LevelingSystemPath", "./Data/Resources/LevelingSystem");
|
||||||
|
Config.AddValueToVariables("LevelingSystemSettingsFile", "./Data/Resources/LevelingSystemSettings.txt");
|
||||||
|
|
||||||
|
if (!File.Exists(Config.GetValue("LevelingSystemSettingsFile")))
|
||||||
|
{
|
||||||
|
globalSettings = new Settings { TimeToWaitBetweenMessages = 5 };
|
||||||
|
await Functions.SaveToJsonFile<Settings>(Config.GetValue("LevelingSystemSettingsFile"), globalSettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
globalSettings = await Functions.ConvertFromJson<Settings>(Config.GetValue("LevelingSystemSettingsFile"));
|
||||||
|
|
||||||
|
// Console.WriteLine(globalSettings.TimeToWaitBetweenMessages);
|
||||||
client.MessageReceived += ClientOnMessageReceived;
|
client.MessageReceived += ClientOnMessageReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +39,7 @@ namespace EVE_LevelingSystem
|
|||||||
if (File.Exists($"{Config.GetValue("LevelingSystemPath")}/{userID}.dat"))
|
if (File.Exists($"{Config.GetValue("LevelingSystemPath")}/{userID}.dat"))
|
||||||
{
|
{
|
||||||
user = await Functions.ConvertFromJson<User>(Config.GetValue("LevelingSystemPath")! + $"/{userID}.dat");
|
user = await Functions.ConvertFromJson<User>(Config.GetValue("LevelingSystemPath")! + $"/{userID}.dat");
|
||||||
Console.WriteLine(Config.GetValue("LevelingSystemPath"));
|
// Console.WriteLine(Config.GetValue("LevelingSystemPath"));
|
||||||
if (user.AddEXP()) await arg.Channel.SendMessageAsync($"{arg.Author.Mention} is now level {user.CurrentLevel}");
|
if (user.AddEXP()) await arg.Channel.SendMessageAsync($"{arg.Author.Mention} is now level {user.CurrentLevel}");
|
||||||
await Functions.SaveToJsonFile(Config.GetValue("LevelingSystemPath") + $"/{userID}.dat", user);
|
await Functions.SaveToJsonFile(Config.GetValue("LevelingSystemPath") + $"/{userID}.dat", user);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using PluginManager;
|
||||||
|
|
||||||
namespace EVE_LevelingSystem.LevelingSystemCore
|
namespace EVE_LevelingSystem.LevelingSystemCore
|
||||||
{
|
{
|
||||||
@@ -44,7 +45,7 @@ namespace EVE_LevelingSystem.LevelingSystemCore
|
|||||||
|
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
int minutesToWait = 0;
|
int minutesToWait = Level.globalSettings.TimeToWaitBetweenMessages;
|
||||||
Thread.Sleep(60000 * minutesToWait);
|
Thread.Sleep(60000 * minutesToWait);
|
||||||
OnWaitingList.Remove(user.userID);
|
OnWaitingList.Remove(user.userID);
|
||||||
}
|
}
|
||||||
|
|||||||
13
EVE_LevelingSystem/Settings.cs
Normal file
13
EVE_LevelingSystem/Settings.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EVE_LevelingSystem
|
||||||
|
{
|
||||||
|
public class Settings
|
||||||
|
{
|
||||||
|
public int TimeToWaitBetweenMessages { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -264,7 +264,7 @@ namespace PluginManager.Others
|
|||||||
|
|
||||||
public static async Task SaveToJsonFile<T>(string file, T Data)
|
public static async Task SaveToJsonFile<T>(string file, T Data)
|
||||||
{
|
{
|
||||||
string jsonText = JsonSerializer.Serialize(Data, typeof(T));
|
string jsonText = JsonSerializer.Serialize(Data, typeof(T), new JsonSerializerOptions() { WriteIndented = true });
|
||||||
await File.WriteAllTextAsync(file, jsonText);
|
await File.WriteAllTextAsync(file, jsonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user