Example #1
0
        public async Task AddReminderAsync(DateTime dueDate, [Remainder] string remainder)
        {
            SocketUser user     = Context.User;
            Reminder   reminder = new Reminder
            {
                UserId     = $"{user.Id}",
                Username   = user.Username,
                CreateDate = DateTime.Now,
                DueDate    = dueDate,
                Duration   = dueDate - DateTime.Now,
                Message    = remainder
            };

            try
            {
                await db.Reminders.AddAsync(reminder);

                await db.SaveChangesAsync();
                await ReplyAsync(InfoMessage.SuccessfullyAdded(reminder));
            }
            catch (Exception ex)
            {
                await ReplyAsync(ErrorMessage.DatabaseAccess());

                Console.WriteLine(ex.Message);
                throw;
            }
        }
Example #2
0
        public async Task AddGameAsync(string name, string port = "?", string version = "?")
        {
            if (name is null)
            {
                await ReplyAsync($"Incorrect struncture, use: \"[game]\" \"[port]\" \"[version]\"");

                return;
            }
            else
            {
                Game game = new Game {
                    Name = name, Port = port, Version = version
                };
                await db.AddAsync(game);

                await db.SaveChangesAsync();
                await ReplyAsync(InfoMessage.SuccessfullyAdded(game));
            }
        }
Example #3
0
        public async Task AddMemeAsync([Remainder] string url)
        {
            try
            {
                Meme meme = new Meme
                {
                    Author = Context.User.Username,
                    Url    = url
                };

                db.Memes.Add(meme);
                await db.SaveChangesAsync();
                await ReplyAsync(InfoMessage.SuccessfullyAdded(meme));
            }
            catch (Exception ex)
            {
                await ReplyAsync(ErrorMessage.DatabaseAccess());

                Console.WriteLine(ex.Message);
                throw;
            }
        }
Example #4
0
        public async Task AddJokeAsync([Remainder] string jokeText)
        {
            try
            {
                Joke joke = new Joke
                {
                    Author = Context.User.Username,
                    Text   = jokeText
                };

                db.Jokes.Add(joke);
                await db.SaveChangesAsync();
                await ReplyAsync(InfoMessage.SuccessfullyAdded(joke));
            }
            catch (Exception ex)
            {
                await ReplyAsync(ErrorMessage.DatabaseAccess());

                Console.WriteLine(ex.Message);
                throw;
            }
        }