public VoiceKickHandler(DiscordSocketClient c) { client = c; WebSocketServer.AddCustomEvent("events.voicekick.add", HandleVoicekickAdd); WebSocketServer.AddCustomEvent("events.voicekick.revoke", HandleVoicekickRevoke); // Setup the events client.UserVoiceStateUpdated += CheckIfVoiceKicked; // load from state try { CurrentVoiceKicked = SwissbotStateHandler.LoadObject <List <VoiceKickUser> >("VoiceKicked.json").Result; } catch { } // Setup the timer System.Timers.Timer t = new System.Timers.Timer() { AutoReset = true, Interval = 1000, }; t.Elapsed += HandleElapsed; t.Start(); }
public static void SaveRoleCard() { string json = JsonConvert.SerializeObject(RoleAssignerHandler.Rolecard, Formatting.Indented); File.WriteAllText(RoleCardFilepath, json); SwissbotStateHandler.SaveObject("RoleCards.json", RoleAssignerHandler.Rolecard); }
public static Dictionary <string, string> LoadSnippets() { //string json = File.ReadAllText(SnippetsFilePath); //if (json == "") // return new Dictionary<string, string>(); //else // return JsonConvert.DeserializeObject<Dictionary<string,string>>(json); return(SwissbotStateHandler.LoadObject <Dictionary <string, string> >("Snippets.json").GetAwaiter().GetResult()); }
public static List <SupportTicket> ReadSupportTickets() { //var json = File.ReadAllText(SupportTicketJsonPath); //if (json == "") // return new List<SupportTicket>(); //else // return JsonConvert.DeserializeObject<List<SupportTicket>>(json); return(SwissbotStateHandler.LoadObject <List <SupportTicket> >("Tickets.json").GetAwaiter().GetResult()); }
public AmongUsClientMapper(DiscordSocketClient c) { Task.Run(async() => { ClientMaps = await SwissbotStateHandler.LoadObject <Dictionary <ulong, ulong> >("ClientMap.json"); }); client = c; }
public static List <ulong> LoadBlockedUsers() { //string json = File.ReadAllText(BlockedUsersPath); //if (json == "") // return new List<ulong>(); //else // return JsonConvert.DeserializeObject<>(json); return(SwissbotStateHandler.LoadObject <List <ulong> >("BlockedUsers.json").GetAwaiter().GetResult()); }
public static void SaveSupportTickets() { var ticks = SupportTicketHandler.CurrentTickets; ticks.ForEach(x => x.DMTyping.TypingObject = null); //ticks.ForEach(x => x.DmTyping.TypingObject = null); //string json = JsonConvert.SerializeObject(ticks, Formatting.Indented); //File.WriteAllText(SupportTicketJsonPath, json); SwissbotStateHandler.SaveObject("Tickets.json", ticks); }
//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>()); } }
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>()); } }
public static List <AutoModHandler.SlowmodeChannel> LoadAutoSlowmode() { try { return(SwissbotStateHandler.LoadObject <List <AutoModHandler.SlowmodeChannel> >("AutoSlowmode.json").GetAwaiter().GetResult()); } catch { return(new List <AutoModHandler.SlowmodeChannel>()); } }
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>()); } }
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()); } }
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(); }
public void SaveAskTimes() => SwissbotStateHandler.SaveObject("ask-times.json", AskTimes);
public static void SaveBlockedUsers() { SwissbotStateHandler.SaveObject("BlockedUsers.json", SupportTicketHandler.BlockedUsers); }
public void SaveMap() => SwissbotStateHandler.SaveObject("ClientMap.json", ClientMaps);
public static void SaveSnippets() { SwissbotStateHandler.SaveObject("Snippets.json", SupportTicketHandler.Snippets); }
public void SaveWhitelist() => SwissbotStateHandler.SaveObject("Whitelist.json", WhiteList);
public static void SaveVoiceKicked() => SwissbotStateHandler.SaveObject("VoiceKicked.json", CurrentVoiceKicked);
private static void SaveTempBans() { SwissbotStateHandler.SaveObject("TempBans.json", TempBans); }
public static void SaveAutoSlowmode() { SwissbotStateHandler.SaveObject("AutoSlowmode.json", AutoModHandler.CurrentSlowmodes); }
public static Dictionary <ulong, ulong> ReadAltCards() { return(SwissbotStateHandler.LoadObject <Dictionary <ulong, ulong> >("AltCards.json").GetAwaiter().GetResult()); }
public static void SaveMutedUsers() { SwissbotStateHandler.SaveObject("MutedUsers.json", MutedHandler.CurrentMuted); }
public void Save() => SwissbotStateHandler.SaveObject("EventSettings", this);
public static void SaveSuggestions() { SwissbotStateHandler.SaveObject("Suggestions.json", SuggestionHandler.CurrentSuggestions); }
public static void SaveCensor() { SwissbotStateHandler.SaveObject("Censor.json", CensoredWords); }
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>(); } }
public static void SaveAltCards() { SwissbotStateHandler.SaveObject("AltCards.json", VerificationHandler.FList); }