/// <summary> /// Timesout a user in chat using a string for the channel. /// </summary> /// <param name="client">Client reference used to identify extension.</param> /// <param name="channel">Channel in string form to send timeout to</param> /// <param name="viewer">Viewer name to timeout</param> /// <param name="duration">Duration of the timeout via TimeSpan object</param> /// <param name="message">Message to accompany the timeout and show the user.</param> /// <param name="dryRun">Indicates a dryrun (will not sened if true)</param> public static void TimeoutUser(this ITwitchClient client, string channel, string viewer, TimeSpan duration, string message = "", bool dryRun = false) { JoinedChannel joinedChannel = client.GetJoinedChannel(channel); if (joinedChannel != null) { TimeoutUser(client, joinedChannel, viewer, duration, message, dryRun); } }
/// <summary> /// Bans a user in chat using a string for the channel /// </summary> /// <param name="client">Client reference used to identify extension.</param> /// <param name="channel">Channel in string form to send ban to</param> /// <param name="viewer">Viewer name to ban</param> /// <param name="message">Message to accompany the ban and show the user.</param> /// <param name="dryRun">Indicates a dryrun (will not send if true)</param> public static void BanUser(this ITwitchClient client, string channel, string viewer, string message = "", bool dryRun = false) { JoinedChannel joinedChannel = client.GetJoinedChannel(channel); if (joinedChannel != null) { BanUser(client, joinedChannel, viewer, message, dryRun); } }
/// <summary> /// Unbans a user in chat using a string for the channel /// </summary> /// <param name="channel">Channel in string form to send unban to</param> /// <param name="viewer">Viewer name to unban</param> /// <param name="dryRun">Indicates a dryrun (will not send if true)</param> /// /// <param name="client">Client reference used to identify extension.</param> public static void UnbanUser(this ITwitchClient client, string channel, string viewer, bool dryRun = false) { var joinedChannel = client.GetJoinedChannel(channel); if (joinedChannel != null) { UnbanUser(client, joinedChannel, viewer, dryRun); } }
private static Task <JoinedChannel> JoinChannel(ITwitchClient client, string channel) { var source = new TaskCompletionSource <JoinedChannel>(); void OnJoinedChannel(object sender, OnJoinedChannelArgs e) { if (e.Channel == channel) { client.OnJoinedChannel -= OnJoinedChannel; source.SetResult(client.GetJoinedChannel(channel)); } } client.OnJoinedChannel += OnJoinedChannel; client.JoinChannel(channel); return(source.Task); }