コード例 #1
0
        public async Task AddReminder([Remainder] string args)
        {
            string[] splittedArgs = null;
            if (args.Contains(" in "))
            {
                splittedArgs = args.Split(new string[] { " in " }, StringSplitOptions.None);
            }
            if (splittedArgs == null || splittedArgs.Length < 2)
            {
                await ReplyAsync("I think you are confused about how to use this command... aren't you?\n" +
                                 "Let me REMIND you it is: `remind DO THE THING! :rage: in 2d 23h 3m 12s`\n" +
                                 "And the ` in ` before the timeparameters is very important you little dumbo you...");

                return;
            }

            var timeString = splittedArgs[splittedArgs.Length - 1];

            if (timeString == "24h")
            {
                timeString = "1d";
            }

            splittedArgs[splittedArgs.Length - 1] = "";
            var reminderString = string.Join(" in ", splittedArgs, 0, splittedArgs.Length - 1);

            var timeDateTime = DateTime.UtcNow + TimeSpan.ParseExact(timeString, ReminderFormat.Formats, CultureInfo.CurrentCulture);

            var newReminder = new ReminderEntry(timeDateTime, reminderString);

            var account = _globalUserAccounts.GetById(Context.User.Id);

            account.Reminders.Add(newReminder);
            _globalUserAccounts.SaveAccounts(Context.User.Id);


            var          timezone  = account.TimeZone ?? "UTC";
            TimeZoneInfo tz        = TimeZoneInfo.FindSystemTimeZoneById($"{timezone}");
            var          localTime = TimeZoneInfo.ConvertTimeFromUtc(timeDateTime, tz);

            var bigmess2 =
                $"{reminderString}\n\n" +
                $"We will send you a DM in  __**{localTime}**__ `by {timezone}`\n";

            var embed = new EmbedBuilder();

            embed.WithAuthor(Context.User);
            embed.WithCurrentTimestamp();
            embed.WithColor(Color.Blue);
            embed.WithTitle("I will remind you through DM:");
            embed.AddField($"**____**", $"{bigmess2}");

            ReplyAsync("", false, embed.Build());
        }
コード例 #2
0
        public async Task ShowTag(string tagName = "")
        {
            if (string.IsNullOrWhiteSpace(tagName))
            {
                await ReplyAsync("You need to use this with some more input...\n" +
                                 "Try the `help ptag` command to get more information on how to use this command.");

                return;
            }
            var userAcc  = _globalUserAccounts.GetById(Context.User.Id);
            var response = TagFunctions.GetTag(tagName, userAcc);

            await ReplyAsync(response);
        }
コード例 #3
0
        public async Task HandleMessageRewards(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            if (msg.Channel == msg.Author.GetOrCreateDMChannelAsync())
            {
                return;
            }
            if (msg.Author.IsBot)
            {
                return;
            }

            var      userAcc = _globalUserAccounts.GetById(msg.Author.Id);
            DateTime now     = DateTime.UtcNow;

            // Check if message is long enough and if the coolown of the reward is up - if not return
            if (now < userAcc.LastMessage.AddSeconds(Constants.MessageRewardCooldown) || msg.Content.Length < Constants.MessageRewardMinLenght)
            {
                return; // This Message is not eligible for a reward
            }

            // Generate a randomized reward in the configured boundries
            userAcc.Miunies    += (ulong)Global.Rng.Next(Constants.MessagRewardMinMax.Item1, Constants.MessagRewardMinMax.Item2 + 1);
            userAcc.LastMessage = now;

            _globalUserAccounts.SaveAccounts(msg.Author.Id);
        }
コード例 #4
0
        public async Task SetMyCity([Remainder] string city)
        {
            var timeZone = ConvertCityToTimeZoneName(city);

            if (timeZone.Result == "error")
            {
                await ReplyAsync("Something went wrong... Try to check your spelling");

                return;
            }

            var account = _globalUserAccounts.GetById(Context.User.Id);

            account.TimeZone = $"{timeZone.Result}";
            _globalUserAccounts.SaveAccounts(Context.User.Id);

            await ReplyAsync($"We saved it. Your TimeZone is **{timeZone.Result}**");
        }
コード例 #5
0
        public async Task CheckMiunies()
        {
            var account = _globalUserAccounts.GetById(Context.User.Id);

            await ReplyAsync(GetMiuniesReport(account.Miunies, Context.User.Mention));
        }