Example #1
0
        public async Task away([Remainder] string message)
        {
            var sb = new StringBuilder();

            try
            {
                var data    = new awaydata();
                var away    = new Away();
                var attempt = data.getAwayUser(Context.User.Username);
                if (!string.IsNullOrEmpty(attempt.User))
                {
                    away.Status  = attempt.Status;
                    away.Message = attempt.Message;
                    away.User    = attempt.User;
                }
                else
                {
                    away.User = Context.User.Username;
                }

                if (string.IsNullOrEmpty(message.ToString()))
                {
                    message = "No message set!";
                }
                if (Context.User.Username == away.User)
                {
                    if (away.Status)
                    {
                        sb.AppendLine($"You're already away, **{Context.User.Mention}**!");
                    }
                    else
                    {
                        sb.AppendLine($"Marking you as away, {Context.User.Mention}, with the message: {message.ToString()}");
                        away.ToggleAway();
                        away.SetMessage(message.ToString());
                        away.User = Context.User.Username;
                        var awayData = new awaydata();
                        awayData.setAwayUser(away);
                    }
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine($"Away command error {ex.Message}");
                sb.AppendLine($"Sorry {Context.User.Mention}, something went wrong with the away command :(");
            }
            finally
            {
                await Context.Channel.SendMessageAsync(sb.ToString());
            }
        }
Example #2
0
        public async Task back()
        {
            var sb = new StringBuilder();

            try
            {
                var data    = new awaydata();
                var attempt = data.getAwayUser(Context.User.Username);
                var away    = new Away();
                if (!string.IsNullOrEmpty(attempt.User))
                {
                    away.Status  = attempt.Status;
                    away.Message = attempt.Message;
                    away.User    = attempt.User;
                }
                else
                {
                    away.User = Context.User.Username;
                }
                if (Context.User.Username == away.User)
                {
                    if (away.Status)
                    {
                        sb.AppendLine($"you're now set as back{Context.User.Mention}");
                        away.ToggleAway();
                        away.SetMessage(string.Empty);
                        var awaydata = new awaydata();
                        awaydata.setAwayUser(away);
                    }
                    else
                    {
                        sb.AppendLine($"you are not even away yet {Context.User.Mention}");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"away commannd error {ex.Message}");
                sb.AppendLine($"sorry {Context.User.Mention} something went wrong with back command");
            }
            finally
            {
                await Context.Channel.SendMessageAsync(sb.ToString());
            }
        }