private bool TryAssignRoleToUser(User user, Role role) { try { user.AddRoles(new Role[] { role }); Bot.NotifyDevs("Added Role **" + role.Name + "** to user **" + user.Name + "** on server **" + user.Server.Name + "**"); try { if (Bot.Config.GamesSyncNotifyUsers) { if (TryGetTextChannel(role.Name, user.Server, out var tChannel)) { Bot.SendMessage("Sup " + role.Mention + " player, " + user.Mention, tChannel); } } } catch (Exception e) { Bot.NotifyDevs(Supporter.BuildExceptionMessage(e, "TryAssignRoleToUser", new object[] { user.Server.Name, user.Name, role.Name })); } return(true); } catch (Exception e) { Bot.NotifyDevs(Supporter.BuildExceptionMessage(e, this.GetType().FullName)); return(false); } }
public void RegisterTwitchChannel(string name, Channel channel = null) { using (var client = new HttpClient()) { string request = string.Format("https://api.twitch.tv/kraken/channels/{0}?client_id={1}" , name , Bot.Config.TwitchAPIKey); try { var response = client.GetStringAsync(request); response.Wait(); var channelObject = JObject.Parse(response.Result); Jenkins.Twitch.AddTwitchChannel(channelObject); } catch (Exception e) { Bot.NotifyDevs(Supporter.BuildExceptionMessage(e, "RegisterTwitchChannel()", request)); if (channel != null) { Bot.SendMessage("There's no Twitch-Channel called **" + name + "** :(", channel); } } } }