-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Moderation): requiring moderationlogs
- Loading branch information
Showing
5 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Reflection; | ||
using DiscordLab.Bot.API.Interfaces; | ||
using Exiled.API.Features; | ||
using Exiled.API.Interfaces; | ||
using Exiled.Loader; | ||
|
||
namespace DiscordLab.Moderation.Handlers | ||
{ | ||
public class ModerationLogsHandler : IRegisterable | ||
{ | ||
public static ModerationLogsHandler Instance { get; private set; } | ||
|
||
private Type HandlerType { get; set; } | ||
public bool IsEnabled; | ||
public object HandlerInstance { get; private set; } | ||
public MethodInfo SendBanLogMethod { get; private set; } | ||
public MethodInfo SendUnbanLogMethod { get; private set; } | ||
|
||
public void Init() | ||
{ | ||
Instance = this; | ||
IPlugin<IConfig> moderationPlugin = Loader.Plugins.FirstOrDefault(p => p.Name == "DiscordLab.ModerationLogs"); | ||
if (moderationPlugin == null) | ||
{ | ||
IsEnabled = false; | ||
return; | ||
} | ||
|
||
IsEnabled = moderationPlugin.Config.IsEnabled; | ||
|
||
Assembly assembly = moderationPlugin.Assembly; | ||
|
||
HandlerType = assembly.GetType("DiscordLab.ModerationLogs.Handlers.DiscordBot"); | ||
HandlerInstance = HandlerType.GetProperty("Instance")!.GetValue(null); | ||
Log.Info(HandlerInstance); | ||
SendBanLogMethod = HandlerType.GetMethod("SendBanMessage")!; | ||
SendUnbanLogMethod = HandlerType.GetMethod("SendUnbanMessage")!; | ||
} | ||
|
||
public void Unregister() | ||
{ | ||
HandlerType = null; | ||
HandlerInstance = null; | ||
SendBanLogMethod = null; | ||
SendUnbanLogMethod = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters