public async Task Suggest([Remainder] string Input = "") { try { if (Input.Equals("") || Input.Length > 150) { return; //Filter out bad input } TextInfo myTI = new CultureInfo("en-US", false).TextInfo; Input = Input.Trim(); //Clear spaces Input = myTI.ToTitleCase(Input); //Make it so every word starts with an upper case ServerData sd = ServerData.Get(Context.Guild); if (sd.DrunkoModeEnabled == true) { await Context.Channel.SendMessageAsync("Hey, suggestions are disabled right now."); return; } Movie m = sd.GetMovie(Input); if (m != null) { if (m.Watched) { await Context.Channel.SendMessageAsync($"The movie {Input} has already been watched."); return; } else { await Context.Channel.SendMessageAsync($"The movie {Input} has already been suggested."); return; } } sd.AddMovie(Input); await Context.Channel.SendMessageAsync($"Your suggestion of {Input} has been added to the list."); Movie mov = sd.GetMovie(Input); Program.Instance.OnMoviesListModified?.Invoke(m, Context.Guild, Context.Channel, Context.User); return; } catch (DataException ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); await Context.Channel.SendMessageAsync("Your server is not in my database, please have a user with the role of 'Movie Master' run the initialize command! :flushed:"); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:"); } }
public async Task RemoveMovie([Remainder] string Input = "") { try { SocketGuildUser user = Context.User as SocketGuildUser; ServerData sd = ServerData.Get(Context.Guild); var role = (user as IGuildUser).Guild.Roles.FirstOrDefault(x => x.Name == sd.AdminRoleName); if (user.Roles.Contains(role)) { //Input sanitization if (Input.Equals("") || Input.Length > 150) { return; //Filter out bad input } TextInfo myTI = new CultureInfo("en-US", false).TextInfo; Input = Input.Trim(); //Clear spaces Input = myTI.ToTitleCase(Input); //Make it so every word starts with an upper case //Check if the movie has been suggested Movie m = sd.GetMovie(Input); if (m == null) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie {Input} has not been suggested or watched."); return; } sd.RemoveMove(Input); await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie {Input} has been removed."); Program.Instance.OnMoviesListModified?.Invoke(m, Context.Guild, Context.Channel, Context.User); } else { await Context.Channel.SendMessageAsync($"{Context.User.Username}, you need to have the role {sd.AdminRoleName} to use this command."); } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A data related exception was raised.", ex)); await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:"); } catch (Exception ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A general exception was raised.", ex)); await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:"); } }
public async Task SetUnwatched([Remainder] string Input = "") { try { //Input sanitization if (Input.Equals("") || Input.Length > 150) { return; //Filter out bad input } TextInfo myTI = new CultureInfo("en-US", false).TextInfo; Input = Input.Trim(); //Clear spaces Input = myTI.ToTitleCase(Input); //Make it so every word starts with an upper case //Check if the movie has been suggested ServerData sd = ServerData.Get(Context.Guild); Movie m = sd.GetMovie(Input); if (m == null) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie {Input} has not been watched yet."); return; } if (!m.Watched) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie {Input} has not been set to watched yet."); return; } m.Watched = false; await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie {Input} has been added back to the wait list and will show in future votes.\nTo undo this, you can use **m!set_watched {Input}**."); Program.Instance.OnMoviesListModified?.Invoke(m, Context.Guild, Context.Channel, Context.User); } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A data related exception was raised.", ex)); await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:"); } catch (Exception ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Voting", "A general exception was raised.", ex)); await Context.Channel.SendMessageAsync("I'm not really sure what happened but something went wrong while executing that command, sorry. :flushed:"); } }