///////////////////////////////////////////////////util/////////////////// /// <summary> /// call back for geting the sound board back /// </summary> void _SoundBoardListUpDate() { lock (SoundBoardBinding) SoundBoardBinding = _ControlPannel.SoundBoardBinding; }
public DiscordBotWorker(Form1 ControlPannel, string[] _GamesToPlay, SoundBoardList _SoundBoardBinding) { _ControlPannel = ControlPannel; #if DEBUG ConsoleWrite("is Debug build\n"); #else ConsoleWrite("is Chidori build\n"); #endif ConsoleWrite("Building Client......"); _DiscordClient = new DiscordClient() .UsingAudio(x => { x.Mode = AudioMode.Both; x.EnableEncryption = true; x.Bitrate = AudioServiceConfig.MaxBitrate; x.BufferLength = 10000; }); //configsfor things #if DEBUG //the sound cloud client config SCClient = new SoundCloudClient("9789f855276cf2c76bf4c6b62a09155e"); track.ToStringOverRide = x => { return(x != null ? "```Title: " + x.title + "\nID : " + x.id + "\nstreamable : " + x.streamable + "\nstream_url:" + x.stream_url + "```" : null); }; #endif //the anime client config _MyAnimeListClient = new MyAnimeListClient("The_True_Trooper", "Jim456852,.,"); Manga.ToStringOverRide = x => { return(x != null ? "```Title: " + x.title + "\nEnglish: " + x.english + "\nSynonyms: " + x.synonyms + "\nChapters: " + x.chapters + "\nVolumes: " + x.volumes + "\nScore: " + x.score + "\nType: " + x.type + "\nStatus: " + x.status + "\nStart Date: " + x.start_date + "\nEnd Date: " + x.end_date + "\nSynopsis: " + x.synopsis.Replace("<br />", "").Replace("[i]", "").Replace("[/i]", "").HtmlDecode() + "```" + "\nhttp://myanimelist.net/manga/" + x.id : null); }; Anime.ToStringOverRide = x => { return(x != null ? "```Title: " + x.title + "\nEnglish: " + x.english + "\nSynonyms: " + x.synonyms + "\nEpisodes: " + x.episodes + "\nScore: " + x.score + "\nType: " + x.type + "\nStatus: " + x.status + "\nStart Date: " + x.start_date + "\nEnd Date: " + x.end_date + "\nSynopsis: " + x.synopsis.Replace("<br />", "").Replace("[i]", "").Replace("[/i]", "").HtmlDecode() + "```" + "\nhttp://myanimelist.net/anime/" + x.id : null); }; //bot callbacks and event bindings MasterAndCommander = new ControlPannelCommand(_MasterAndCommander); SoundBoardListUpDate = new VoidVoid(_SoundBoardListUpDate); _DiscordClient.Ready += Ready; _DiscordClient.MessageReceived += MessRec; //_DiscordClient.MessageUpdated += MessRec; _DiscordClient.UserJoined += JoinHello; _DiscordClient.JoinedServer += JoinServer; _DiscordClient.UserUpdated += UserUpHello; _DiscordClient.RoleCreated += RoleCreate; _DiscordClient.RoleDeleted += RoleDelete; _DiscordClient.RoleUpdated += RoleUpdate; _DiscordClient.UserBanned += UserBanned; _DiscordClient.UserUnbanned += UserUnbanned; _DiscordClient.ChannelCreated += ChannelCreated; _DiscordClient.ChannelDestroyed += ChannelDeleted; _DiscordClient.ChannelUpdated += ChannelUpdated; ConsoleWrite("Building support classes......"); //ticks info Ticker.Elapsed += Tick; MaxTickOnNewGames = Rand.Next(30); //list populating ConsoleWrite("Populating lists......"); GamesToPlay = null; lock (GamesToPlay) GamesToPlay = GamesToPlay.Concat(_GamesToPlay).ToArray(); SoundBoardBinding = null; lock (SoundBoardBinding) SoundBoardBinding = _SoundBoardBinding; Connect(); }