Formatted code and rebuilt PluginLoader
This commit is contained in:
@@ -13,7 +13,7 @@ public static class ArchiveManager
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
if (IsInitialized)
|
||||
throw new Exception("ArchiveManager is already initialized");
|
||||
|
||||
if (!Config.AppSettings.ContainsKey("ArchiveFolder"))
|
||||
@@ -89,7 +89,7 @@ public static class ArchiveManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(message: ex.Message, source: typeof(ArchiveManager), type: LogType.ERROR); // Write the error to a file
|
||||
Config.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR); // Write the error to a file
|
||||
await Task.Delay(100);
|
||||
return await ReadFromPakAsync(fileName, archFile);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public static class ArchiveManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(ex.Message, source: typeof(ArchiveManager), type: LogType.ERROR);
|
||||
Config.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR);
|
||||
}
|
||||
|
||||
currentZipFile++;
|
||||
@@ -158,7 +158,7 @@ public static class ArchiveManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(ex.Message, source: typeof(ArchiveManager), type: LogType.ERROR);
|
||||
Config.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR);
|
||||
}
|
||||
|
||||
await Task.Delay(10);
|
||||
|
||||
@@ -17,26 +17,26 @@ public class DbCommandExecutingArguments
|
||||
|
||||
public DbCommandExecutingArguments(SocketUserMessage? message, DiscordSocketClient client)
|
||||
{
|
||||
this.context = new SocketCommandContext(client, message);
|
||||
int pos = 0;
|
||||
context = new SocketCommandContext(client, message);
|
||||
var pos = 0;
|
||||
if (message.HasMentionPrefix(client.CurrentUser, ref pos))
|
||||
{
|
||||
var mentionPrefix = "<@" + client.CurrentUser.Id + ">";
|
||||
this.cleanContent = message.Content.Substring(mentionPrefix.Length + 1);
|
||||
cleanContent = message.Content.Substring(mentionPrefix.Length + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cleanContent = message.Content.Substring(Config.DiscordBot.botPrefix.Length);
|
||||
cleanContent = message.Content.Substring(Config.DiscordBot.botPrefix.Length);
|
||||
}
|
||||
|
||||
var split = this.cleanContent.Split(' ');
|
||||
var split = cleanContent.Split(' ');
|
||||
|
||||
string[]? argsClean = null;
|
||||
if (split.Length > 1)
|
||||
argsClean = string.Join(' ', split, 1, split.Length - 1).Split(' ');
|
||||
|
||||
this.commandUsed = split[0];
|
||||
this.arguments = argsClean;
|
||||
commandUsed = split[0];
|
||||
arguments = argsClean;
|
||||
}
|
||||
|
||||
public SocketCommandContext context { get; init; }
|
||||
|
||||
@@ -32,10 +32,18 @@ public enum InternalActionRunType
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum OSType : byte
|
||||
public enum OSType: byte
|
||||
{
|
||||
NONE = 0,
|
||||
NONE = 0,
|
||||
WINDOWS = 1 << 0,
|
||||
LINUX = 2 << 1,
|
||||
MACOSX = 3 << 2,
|
||||
}
|
||||
LINUX = 2 << 1,
|
||||
MACOSX = 3 << 2
|
||||
}
|
||||
|
||||
public enum PluginType
|
||||
{
|
||||
UNKNOWN,
|
||||
COMMAND,
|
||||
EVENT,
|
||||
SLASH_COMMAND
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ public class JsonManager
|
||||
public static async Task SaveToJsonFile<T>(string file, T Data)
|
||||
{
|
||||
var str = new MemoryStream();
|
||||
await JsonSerializer.SerializeAsync(str, Data, typeof(T), new JsonSerializerOptions { WriteIndented = true });
|
||||
await JsonSerializer.SerializeAsync(str, Data, typeof(T), new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
}
|
||||
);
|
||||
await File.WriteAllBytesAsync(file, str.ToArray());
|
||||
await str.FlushAsync();
|
||||
str.Close();
|
||||
|
||||
@@ -43,9 +43,15 @@ public class Log: ILog
|
||||
ThrowTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public static implicit operator Log(string message) => new(message);
|
||||
public static implicit operator Log(string message)
|
||||
{
|
||||
return new Log(message);
|
||||
}
|
||||
|
||||
public static implicit operator string(Log log) => $"[{log.ThrowTime}] {log.Message}";
|
||||
public static implicit operator string(Log log)
|
||||
{
|
||||
return $"[{log.ThrowTime}] {log.Message}";
|
||||
}
|
||||
|
||||
public string AsLongString()
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SettingsDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
{
|
||||
if (File.Exists(_file))
|
||||
{
|
||||
string FileContent = File.ReadAllText(_file);
|
||||
var FileContent = File.ReadAllText(_file);
|
||||
if (string.IsNullOrEmpty(FileContent))
|
||||
File.WriteAllText(_file, "{}");
|
||||
|
||||
@@ -66,62 +66,62 @@ public class SettingsDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
this._dictionary!.Add(item);
|
||||
_dictionary!.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
this._dictionary!.Clear();
|
||||
_dictionary!.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return this._dictionary!.Contains(item);
|
||||
return _dictionary!.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
this._dictionary!.CopyTo(array, arrayIndex);
|
||||
_dictionary!.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return this._dictionary!.Remove(item);
|
||||
return _dictionary!.Remove(item);
|
||||
}
|
||||
|
||||
public int Count => _dictionary!.Count;
|
||||
public bool IsReadOnly => _dictionary!.IsReadOnly;
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
this._dictionary!.Add(key, value);
|
||||
_dictionary!.Add(key, value);
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return this._dictionary!.ContainsKey(key);
|
||||
return _dictionary!.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
return this._dictionary!.Remove(key);
|
||||
return _dictionary!.Remove(key);
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
return this._dictionary!.TryGetValue(key, out value);
|
||||
return _dictionary!.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._dictionary!.ContainsKey(key))
|
||||
if (this._dictionary[key] is string s && !string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s))
|
||||
return this._dictionary[key];
|
||||
if (_dictionary!.ContainsKey(key))
|
||||
if (_dictionary[key] is string s && !string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s))
|
||||
return _dictionary[key];
|
||||
|
||||
return default!;
|
||||
}
|
||||
set => this._dictionary![key] = value;
|
||||
set => _dictionary![key] = value;
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys => _dictionary!.Keys;
|
||||
|
||||
Reference in New Issue
Block a user