コード例 #1
0
        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:");
            }
        }