public async Task SetMovieTime([Summary("The number of movies to be selected.")] int number = 1) { 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)) { if (number < 0 || number > 23) { await Context.Channel.SendMessageAsync($"{Context.User.Username} the time must be within the range of 0 to 23!"); } await Context.Channel.SendMessageAsync($"{Context.User.Username}, the movie time will now show as {number}! This will show up in the embed timestamp converted to user's local time zone!"); sd.MovieTimeHour = number; } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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 VoteCount([Summary("The number of movies a user may vote on.")] int number = 5) { 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)) { if (number < 1) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the number of votes must be greater than 0."); return; } if (number > sd.MovieVoteOptionCount) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the number of votes must be greater than the number of movies that show in a vote. To modify the number of movies in a vote use **m!movie_vote_count**"); return; } await Context.Channel.SendMessageAsync($"{Context.User.Username}, users will be allowed to place {number} votes."); sd.UserVoteLimit = number; } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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 SetAdminRoleName([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)) { if (Input == "") { await Context.Channel.SendMessageAsync($"{Context.User.Username}, you can't set the admin role name to nothing! You dunce!"); } await Context.Channel.SendMessageAsync($"{Context.User.Username}, the admin role name has been updated to {Input}! Please ensure you have this role, or you can't execute administrative commands with me!"); sd.AdminRoleName = Input; } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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 SetMovieCount([Summary("The number of movies to be selected.")] int number = 5) { 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)) { try { //int count = -1; //Input sanitization and filtering if (number.Equals("")) { Console.WriteLine("Empty argument."); return; } //Empty argument if (number < 2) //Valid range check { Console.WriteLine("Can't be less than 2."); await Context.Channel.SendMessageAsync($"{Context.User.Username}, vote count can't be less than 2."); return; } if (number < sd.UserVoteLimit) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, the number of movie options on a vote cannot be smaller than the number of movies a user is allowed to vote for!."); return; } //Set the limit in the server file. sd.MovieVoteOptionCount = number; await Context.Channel.SendMessageAsync($"{Context.User.Username}, from now on {number} movies will show up for votes."); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } } 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, "Server Settings", "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, "Server Settings", "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 GetAdminRoleName() { try { ServerData sd = ServerData.Get(Context.Guild); await Context.User.SendMessageAsync($"The name of the administrative role is currently {sd.AdminRoleName}."); } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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 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 SetTieOption([Remainder] string Input = "") //Because we could all use some from time to time. { 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)) { int option = 0; switch (Input) { case "breaker": option = 0; break; case "random": option = 1; break; default: await Context.User.SendMessageAsync("Unknown argument. For **m!tieoption** the options are *breaker* and *random*. Use **m!help** for more detials."); return; } if (user.Roles.Contains(role)) { //This user is allowed to configure settings. sd.TiebreakerMethod = option; await Context.User.SendMessageAsync($"MovieNightBot will now use the {Input} method for ties."); } } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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:"); } }
public async Task SetDrunkoMode([Summary("The number of movies to be selected.")] int enabled = 0) { 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)) { if (enabled < 0 || enabled > 1) { await Context.Channel.SendMessageAsync($"{Context.User.Username} the setting should be either 0 or 1!"); } if (enabled == 0) { await Context.Channel.SendMessageAsync($"{Context.User.Username}, movie suggestions are re-enabled."); sd.DrunkoModeEnabled = false; } else { await Context.Channel.SendMessageAsync($"{Context.User.Username}, movie suggestions are disabled temporarily."); sd.DrunkoModeEnabled = true; } } } catch (DataException ex) { await Program.Instance.Log(new LogMessage(LogSeverity.Error, "Server Settings", "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, "Server Settings", "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 NewVote([Remainder] string selection = "") { try { //Create instance of servers and votes if it does not already exist. if (ServersAndVotes == null) { ServersAndVotes = new Dictionary <ulong, RankedServerVote>(); } //Vote has already started, do not continue if (ServersAndVotes.ContainsKey(Context.Guild.Id)) { await Context.Channel.SendMessageAsync("A vote is already running, please end the current one before starting a new one!"); return; } ServerData sd = ServerData.Get(Context.Guild); Movie[] movs = null; if (selection == "") { //Get the movies to vote on movs = sd.GetMovieSelection(sd.MovieVoteOptionCount); } else { string[] titles = selection.Split(";"); movs = new Movie[titles.Length]; for (int i = 0; i < movs.Length; i++) { movs[i] = new Movie(); movs[i].Title = titles[i]; } } //Generate the ranked vote object RankedServerVote serverVote = new RankedServerVote(Context.Guild, movs, Context.Channel); //build and send out the voting embed Embed embed = serverVote.MakeVoteEmbed(); //Send the message out RestUserMessage mess = await Context.Channel.SendMessageAsync("Movie Vote!!!", embed : embed).ConfigureAwait(false); Emoji[] votes = new Emoji[movs.Length + 1]; //React with the voting reactions for (int i = 0; i < movs.Length; i++) { votes[i] = MojiCommand.VoteMoji[i]; } votes[votes.Length - 1] = MojiCommand.CommandMoji[1]; await mess.AddReactionsAsync(votes); //Finally add this vote object to the dictionary for later reference serverVote.voteMessage = mess; ServersAndVotes.Add(Context.Guild.Id, serverVote); } 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:"); } }