Guest User

Untitled

a guest
Jul 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. public TwitchBot()
  2. {
  3. connectionCredentials = new ConnectionCredentials(TwitchInfo.BotName, TwitchInfo.AccessToken);
  4. random = new Random();
  5.  
  6. CreateCommands();
  7. Connection();
  8.  
  9. var channelInfo = new TwitchLib.Api.Models.v5.Channels.Channel();
  10. twitchAPI = new TwitchLib.Api.TwitchAPI();
  11. twitchAPI.Settings.ClientId = TwitchInfo.ClientId;
  12. twitchAPI.Settings.AccessToken = TwitchInfo.AccessToken;
  13.  
  14. DisplayResultAsync();
  15. }
  16.  
  17. static async void DisplayResultAsync()
  18. {
  19. await ExampleCallsAsync();
  20. }
  21.  
  22. void Connection()
  23. {
  24. twitchClient = new TwitchClient();
  25. twitchClient.Initialize(connectionCredentials, TwitchInfo.Channel);
  26.  
  27. twitchClient.OnMessageReceived += TwitchClient_OnMessageReceived;
  28. twitchClient.OnWhisperReceived += TwitchClient_OnWhisperReceived;
  29. twitchClient.OnUserJoined += TwitchClient_OnUserJoined;
  30. twitchClient.OnChatCommandReceived += TwitchClient_OnChatCommandReceived;
  31. twitchClient.Connect();
  32. }
  33.  
  34. private static async Task ExampleCallsAsync()
  35. {
  36. //Checks subscription for a specific user and the channel specified.
  37. Subscription subscription = await twitchAPI.Channels.v5.CheckChannelSubscriptionByUserAsync(TwitchInfo.Channel, "stribog45");
  38.  
  39. //Gets a list of all the subscritions of the specified channel.
  40. //var allSubscriptions = await twitchAPI.Channels.v5.GetAllSubscribersAsync(TwitchInfo.Channel);
  41.  
  42. //Get channels a specified user follows.
  43. //GetUsersFollowsResponse userFollows = await twitchAPI.Users.helix.GetUsersFollowsAsync("stribog45");
  44.  
  45. //Get Spedicified Channel Follows
  46. //var channelFollowers = await twitchAPI.Channels.v5.GetChannelFollowersAsync(TwitchInfo.ClientId);
  47.  
  48. //Return bool if channel is online/offline.
  49. bool isStreaming = await twitchAPI.Streams.v5.BroadcasterOnlineAsync(TwitchInfo.Channel);
  50.  
  51. //Update Channel Title/Game
  52. //await twitchAPI.Channels.v5.UpdateChannelAsync("channel_id", "New stream title", "Stronghold Crusader");
  53. }
Add Comment
Please, Sign In to add comment