/// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            var configFile = Path.Combine(StoragePath, "DiscordRoleManager.cfg");

            try
            {
                _config = Persistent <RoleConfig> .Load(configFile);
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }

            if (_config?.Data == null)
            {
                _config = new Persistent <RoleConfig>(configFile, new RoleConfig());
            }

            if (Config.BotToken.Length == 0)
            {
                Log.Warn("No BOT token set, plugin will not work at all! Add your bot TOKEN, save and start torch.");
            }

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }

            var eventManager = Torch.Managers.GetManager <EventManager>();

            if (eventManager != null)
            {
                eventManager.RegisterHandler(new RoleEventHandler());
            }
            else
            {
                Log.Warn("No event manager loaded!");
            }

            ConnectDiscord();

            Instance = this;
        }
Esempio n. 2
0
 public RoleControl(RolePlugin plugin) : this()
 {
     Plugin      = plugin;
     DataContext = plugin.Config;
 }