private async Task <List <GetChannelListInfo> > GetChannelList() { try { var resp = await _teamSpeakClient.GetChannels(); return(resp.ToList()); } catch (Exception e) { _eventLog1?.WriteEntry($"Failed to get ChannelList: {e.Message}", EventLogEntryType.Error); return(null); } }
public async Task ConnectAndLogin() { try { dbid = Convert.ToInt32(configuration.GetSection("Teamspeak:DatabaseID").Value); string server = configuration.GetSection("Teamspeak:Server").Value; string port = configuration.GetSection("Teamspeak:Port").Value; string username = configuration.GetSection("Teamspeak:Username").Value; string password = configuration.GetSection("Teamspeak:Password").Value; nickname = configuration.GetSection("Nickname").Value; tsClient = new TeamSpeakClient(server, Convert.ToInt32(port)); // Create rich client instance await tsClient.Connect(); // connect to the server await tsClient.Login(username, password); // login to do some stuff that requires permission await tsClient.UseServer(1); // Use the server with id '1' #if DEBUG await tsClient.ChangeNickName(nickname + "_DEBUG"); #else await tsClient.ChangeNickName(nickname); #endif botClient = await tsClient.WhoAmI(); await tsClient.MoveClient(botClient.ClientId, 1); await tsClient.RegisterChannelNotification(1); tsClient.Subscribe <ClientMoved>(ClientMoved); await tsClient.RegisterTextChannelNotification(); tsClient.Subscribe <TextMessage>(ChatMessageReceived); var pChannel = await tsClient.GetChannels(); } catch (Exception e) { logger.LogWarning(e.Message); logger.LogWarning(e.StackTrace); } }