Exemple #1
0
 public static List <AutoModHandler.SlowmodeChannel> LoadAutoSlowmode()
 {
     try
     {
         return(SwissbotStateHandler.LoadObject <List <AutoModHandler.SlowmodeChannel> >("AutoSlowmode.json").GetAwaiter().GetResult());
     }
     catch
     {
         return(new List <AutoModHandler.SlowmodeChannel>());
     }
 }
Exemple #2
0
 public static Dictionary <ulong, DateTime> LoadMuted()
 {
     try
     {
         return(SwissbotStateHandler.LoadObject <Dictionary <ulong, DateTime> >("MutedUsers.json").GetAwaiter().GetResult());
     }
     catch (Exception x)
     {
         return(new Dictionary <ulong, DateTime>());
     }
 }
 public Dictionary <ulong, DateTime> LoadAskTimes()
 {
     try
     {
         return(SwissbotStateHandler.LoadObject <Dictionary <ulong, DateTime> >("ask-times.json").GetAwaiter().GetResult());
     }
     catch
     {
         return(new Dictionary <ulong, DateTime>());
     }
 }
Exemple #4
0
        //public static ModlogsJson LoadModlogs()
        //{
        //    try
        //    {
        //        return SwissbotStateHandler.LoadObject<ModlogsJson>("Modlogs.json").GetAwaiter().GetResult();
        //    }
        //    catch (Exception x)
        //    {
        //        return new ModlogsJson();
        //    }

        //}
        //public static void SaveModlogs()
        //{
        //    SwissbotStateHandler.SaveObject("Modlogs.json", ModDatabase.currentLogs);
        //}
        public static List <SuggestionHandler.Suggestion> LoadSuggestions()
        {
            try
            {
                return(SwissbotStateHandler.LoadObject <List <SuggestionHandler.Suggestion> >("Suggestions.json").GetAwaiter().GetResult());
            }
            catch
            {
                return(new List <SuggestionHandler.Suggestion>());
            }
        }
Exemple #5
0
 internal static RoleAssignerHandler.RoleCard ReadRoleCard()
 {
     //return File.ReadAllText(RoleCardFilepath) != "" ? JsonConvert.DeserializeObject<RoleAssignerHandler.RoleCard>(File.ReadAllText(RoleCardFilepath)) : null;
     try
     {
         return(SwissbotStateHandler.LoadObject <RoleAssignerHandler.RoleCard>("RoleCards.json").GetAwaiter().GetResult());
     }
     catch (Exception ex)
     {
         return(new RoleAssignerHandler.RoleCard());
     }
 }
Exemple #6
0
 public async Task <List <string> > LoadWhiteList()
 {
     try
     {
         return(await SwissbotStateHandler.LoadObject <List <string> >("Whitelist.json"));
     }
     catch (Exception x)
     {
         Global.ConsoleLog("Failed to load whitelist, returning empty");
         return(new List <string>());
     }
 }
Exemple #7
0
        public TempBanHandler(DiscordSocketClient c)
        {
            client = c;

            // Load the records
            try
            {
                TempBans = SwissbotStateHandler.LoadObject <List <TempBan> >("TempBans.json").Result;
            }
            catch { }

            client.GuildMemberUpdated += Client_GuildMemberUpdated;

            Timer t = new Timer();

            t.Interval = 3000;

            t.Elapsed += T_Elapsed;

            t.Start();
        }
Exemple #8
0
        public static void ReadConfig()
        {
            if (!Directory.Exists(MessageLogsDir))
            {
                Directory.CreateDirectory(MessageLogsDir);
            }
            if (!Directory.Exists(CommandLogsDir))
            {
                Directory.CreateDirectory(CommandLogsDir);
            }
            //if (!File.Exists(aiResponsePath)) { File.Create(aiResponsePath); }
            if (!File.Exists(CensorPath))
            {
                File.Create(CensorPath);
            }
            if (!File.Exists(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "AltVerifyCards.txt"))
            {
                File.Create(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "AltVerifyCards.txt").Close();
            }
            if (!File.Exists(HelpMessagefilepath))
            {
                File.Create(HelpMessagefilepath).Close();
            }
            if (!File.Exists(RoleCardFilepath))
            {
                File.Create(RoleCardFilepath).Close();
            }
            if (!File.Exists(SupportTicketJsonPath))
            {
                File.Create(SupportTicketJsonPath).Close();
            }
            if (!File.Exists(SnippetsFilePath))
            {
                File.Create(SnippetsFilePath).Close();
            }
            if (!File.Exists(BlockedUsersPath))
            {
                File.Create(BlockedUsersPath).Close();
            }
            var data = JsonConvert.DeserializeObject <JsonItems>(File.ReadAllText(ConfigPath));

            jsonItemsList       = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            JsonItemsListDevOps = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            ConfigSettings      = JsonConvert.DeserializeObject <Dictionary <string, bool> >(File.ReadAllText(ConfigSettingsPath));
            foreach (var item in ConfigSettings)
            {
                if (item.Value == false)
                {
                    jsonItemsList.Remove(item.Key);
                }
            }

            JsonItemsListDevOps.Remove("Token");
            CurrentJsonData             = data;
            SwissbotStateHandler.APIKey = data.StateAPIKey;
            Preflix = data.Preflix;
            WelcomeMessageChanID = data.WelcomeMessageChanID;
            WelcomeMessage       = data.WelcomeMessage;
            WelcomeMessageURL    = data.WelcomeMessageURL;
            Status                = data.Status;
            giveawayChanID        = data.giveawayChanID;
            giveawayCreatorChanId = data.giveawayCreatorChanId;
            Token                 = data.Token;
            StatsChanID           = data.StatsChanID;
            SwissGuildId          = data.SwissGuildID;
            DeveloperRoleId       = data.DeveloperRoleId;
            SwissBotDevGuildID    = data.SwissTestingGuildID;
            LogsChannelID         = data.LogsChannelID;
            DebugChanID           = data.DebugChanID;
            SubmissionChanID      = data.SubmissionChanID;
            TestingCat            = data.TestingCatigoryID;
            ModeratorRoleID       = data.ModeratorRoleID;
            MemberRoleID          = data.MemberRoleID;
            AutoSlowmodeTrigger   = data.AutoSlowmodeTrigger;
            ApiKey                = data.ApiKey;
            AutoSlowmodeToggle    = data.AutoSlowmodeToggle;
            UnverifiedRoleID      = data.UnverifiedRoleID;
            VerificationChanID    = data.VerificationChanID;
            VerificationLogChanID = data.VerificationLogChanID;
            SubmissionsLogChanID  = data.SubmissionsLogChanID;
            MilestonechanID       = data.MilestonechanID;
            BotAiChanID           = data.BotAiChanID;
            VerifyAlts            = data.VerifyAlts;
            AltVerificationHours  = data.AltVerificationHours;
            StatsTotChanID        = data.StatsTotChanID;
            MutedRoleID           = data.MutedRoleID;
            TicketCategoryID      = data.TicketCategoryID;
            SuggestionChannelID   = data.SuggestionChannelID;
            TicketSnippets        = data.TicketSnippets;
            Workers               = data.Workers.Split(' ');

            try
            {
                CensoredWords = SwissbotStateHandler.LoadObject <List <string> >("Censor.json").Result;
            }
            catch
            {
                CensoredWords = new List <string>();
            }
        }
Exemple #9
0
 public static Dictionary <ulong, ulong> ReadAltCards()
 {
     return(SwissbotStateHandler.LoadObject <Dictionary <ulong, ulong> >("AltCards.json").GetAwaiter().GetResult());
 }