static void Main() { //load credentials from credentials.json Credentials c; bool loadTrello = false; try { c = JsonConvert.DeserializeObject <Credentials>(File.ReadAllText("credentials.json")); botMention = c.BotMention; if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") { Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened."); } else { Console.WriteLine("Google API key provided."); GoogleAPIKey = c.GoogleAPIKey; } if (c.TrelloAppKey == null || c.TrelloAppKey == "") { Console.WriteLine("No trello appkey found. You will not be able to use trello commands."); } else { Console.WriteLine("Trello app key provided."); TrelloAppKey = c.TrelloAppKey; loadTrello = true; } if (c.ForwardMessages != true) { Console.WriteLine("Not forwarding messages."); } else { ForwardMessages = true; Console.WriteLine("Forwarding messages."); } OwnerID = c.OwnerID; password = c.Password; } catch (Exception ex) { Console.WriteLine("Failed to load stuff from credentials.json, RTFM"); Console.ReadKey(); return; } //create new discord client client = new DiscordClient(); //create a command service var commandService = new CommandService(new CommandServiceConfig { CommandChar = null, HelpMode = HelpMode.Disable }); //init parse if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") { ParseClient.Initialize(c.ParseID, c.ParseKey); //monitor commands for logging stats_collector = new StatsCollector(commandService); } else { Console.WriteLine("Parse key and/or ID not found. Logging disabled."); } //reply to personal messages and forward if enabled. client.MessageReceived += Client_MessageReceived; //add command service var commands = client.Services.Add <CommandService>(commandService); //create module service var modules = client.Services.Add <ModuleService>(new ModuleService()); //add audio service var audio = client.Services.Add <AudioService>(new AudioService(new AudioServiceConfig() { Channels = 2, EnableEncryption = false, EnableMultiserver = true })); //install modules modules.Add(new Administration(), "Administration", ModuleFilter.None); modules.Add(new Conversations(), "Conversations", ModuleFilter.None); modules.Add(new Gambling(), "Gambling", ModuleFilter.None); modules.Add(new Games(), "Games", ModuleFilter.None); modules.Add(new Music(), "Music", ModuleFilter.None); modules.Add(new Searches(), "Searches", ModuleFilter.None); if (loadTrello) { modules.Add(new Trello(), "Trello", ModuleFilter.None); } //run the bot client.ExecuteAndWait(async() => { await client.Connect(c.Username, c.Password); Console.WriteLine("-----------------"); Console.WriteLine(GetStats()); Console.WriteLine("-----------------"); foreach (var serv in client.Servers) { if ((OwnerUser = serv.GetUser(OwnerID)) != null) { return; } } }); Console.WriteLine("Exiting..."); Console.ReadKey(); }
static void Main() { //load credentials from credentials.json Credentials c; try { c = JsonConvert.DeserializeObject <Credentials>(File.ReadAllText("credentials.json")); botMention = c.BotMention; if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") { Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened."); } else { GoogleAPIKey = c.GoogleAPIKey; } OwnerID = c.OwnerID; password = c.Password; } catch (Exception) { Console.WriteLine("Failed to load stuff from credentials.json, RTFM"); Console.ReadKey(); return; } //create new discord client client = new DiscordClient(); //create a command service var commandService = new CommandService(new CommandServiceConfig { CommandChar = null, HelpMode = HelpMode.Disable }); //init parse if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") { ParseClient.Initialize(c.ParseID, c.ParseKey); //monitor commands for logging stats_collector = new StatsCollector(commandService); } else { Console.WriteLine("Parse key and/or ID not found. Bot will not log."); } //add command service var commands = client.Services.Add <CommandService>(commandService); //create module service var modules = client.Services.Add <ModuleService>(new ModuleService()); //add audio service var audio = client.Services.Add <AudioService>(new AudioService(new AudioServiceConfig() { Channels = 2, EnableEncryption = false })); //install modules modules.Install(new Administration(), "Administration", FilterType.Unrestricted); modules.Install(new Conversations(), "Conversations", FilterType.Unrestricted); modules.Install(new Gambling(), "Gambling", FilterType.Unrestricted); modules.Install(new Games(), "Games", FilterType.Unrestricted); modules.Install(new Music(), "Music", FilterType.Unrestricted); modules.Install(new Searches(), "Searches", FilterType.Unrestricted); //run the bot client.Run(async() => { await client.Connect(c.Username, c.Password); Console.WriteLine("Connected!"); }); Console.WriteLine("Exiting..."); Console.ReadKey(); }
static void Main() { //load credentials from credentials.json Credentials c; try { c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json")); botMention = c.BotMention; if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") { Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened."); } else { GoogleAPIKey = c.GoogleAPIKey; } OwnerID = c.OwnerID; password = c.Password; } catch (Exception) { Console.WriteLine("Failed to load stuff from credentials.json, RTFM"); Console.ReadKey(); return; } //create new discord client client = new DiscordClient(); //create a command service var commandService = new CommandService(new CommandServiceConfig { CommandChar = null, HelpMode = HelpMode.Disable }); //init parse if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") { ParseClient.Initialize(c.ParseID, c.ParseKey); //monitor commands for logging stats_collector = new StatsCollector(commandService); } else { Console.WriteLine("Parse key and/or ID not found. Bot will not log."); } //add command service var commands = client.Services.Add<CommandService>(commandService); //create module service var modules = client.Services.Add<ModuleService>(new ModuleService()); //add audio service var audio = client.Services.Add<AudioService>(new AudioService(new AudioServiceConfig() { Channels = 2, EnableEncryption = false })); //install modules modules.Install(new Administration(), "Administration", FilterType.Unrestricted); modules.Install(new Conversations(), "Conversations", FilterType.Unrestricted); modules.Install(new Gambling(), "Gambling", FilterType.Unrestricted); modules.Install(new Games(), "Games", FilterType.Unrestricted); modules.Install(new Music(), "Music", FilterType.Unrestricted); modules.Install(new Searches(), "Searches", FilterType.Unrestricted); //run the bot client.Run(async () => { await client.Connect(c.Username, c.Password); Console.WriteLine("Connected!"); }); Console.WriteLine("Exiting..."); Console.ReadKey(); }
static void Main() { //load credentials from credentials.json Credentials c; try { c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json")); botMention = c.BotMention; if (c.ForwardMessages != true) Console.WriteLine("Not forwarding messages."); else { ForwardMessages = true; Console.WriteLine("Forwarding messages."); } OwnerID = c.OwnerID; password = c.Password; } catch (Exception ex) { Console.WriteLine("Failed to load stuff from credentials.json, RTFM"); Console.ReadKey(); return; } //create new discord client client = new DiscordClient(); //create a command service var commandService = new CommandService(new CommandServiceConfig { CommandChar = null, HelpMode = HelpMode.Disable }); //init parse if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") { ParseClient.Initialize(c.ParseID, c.ParseKey); //monitor commands for logging stats_collector = new StatsCollector(commandService); } else { Console.WriteLine("Parse key and/or ID not found. Logging disabled."); } //reply to personal messages and forward if enabled. client.MessageReceived += Client_MessageReceived; //add command service var commands = client.Services.Add<CommandService>(commandService); //count commands ran client.Commands().CommandExecuted += (s, e) => commandsRan++; //create module service var modules = client.Services.Add<ModuleService>(new ModuleService()); //add audio service var audio = client.Services.Add<AudioService>(new AudioService(new AudioServiceConfig() { Channels = 2, EnableEncryption = false, EnableMultiserver = true, Bitrate = 128, })); //install modules modules.Add(new Administration(), "Administration", ModuleFilter.None); //run the bot client.ExecuteAndWait(async () => { await client.Connect(c.Username, c.Password); Console.WriteLine("-----------------"); Console.WriteLine(GetStats()); Console.WriteLine("-----------------"); foreach (var serv in client.Servers) { if ((OwnerUser = serv.GetUser(OwnerID)) != null) return; } }); Console.WriteLine("Exiting..."); Console.ReadKey(); }