예제 #1
0
        public KrispyStatusLine()
        {
            var toParse     = KrispyGenerator.PickLine(KrispyLines.Status);
            var isPlaying   = toParse.StartsWith("!p");
            var isWatching  = toParse.StartsWith("!w");
            var isListening = toParse.StartsWith("!l");
            var isStreaming = toParse.StartsWith("!s");

            if (isPlaying || isWatching || isListening || isStreaming)
            {
                if (isPlaying)
                {
                    Type = ActivityType.Playing;
                }
                else if (isWatching)
                {
                    Type = ActivityType.Watching;
                }
                else if (isListening)
                {
                    Type = ActivityType.Listening;
                }
                else
                {
                    Type = ActivityType.Streaming;
                }
                Status = toParse.Substring(3);
            }
            else
            {
                Status = toParse;
            }
        }
예제 #2
0
        public async Task JoinTeamBlue()
        {
            await RemoveTeamRoles(Context.Guild, (IGuildUser)Context.User);

            await((IGuildUser)Context.User).AddRoleAsync(Context.Guild.GetRole((ulong)Teams.Blue));
            await ReplyAsync("Joined Team Blue. " + String.Format(KrispyGenerator.PickLine(KrispyLines.Opposing), "Green"));
        }
예제 #3
0
        public static async Task RemoveGamesContext(SocketCommandContext context, string games)
        {
            var gameRoles = await GetGameRoles(context, games);

            if (gameRoles == null)
            {
                return;
            }
            switch (gameRoles.Count)
            {
            case 0:
                await context.Channel.SendMessageAsync(KrispyGenerator.PickLine(KrispyLines.Disappointed));

                break;

            case 1:
                await((IGuildUser)context.User).RemoveRoleAsync(gameRoles[0]);
                await context.Channel.SendMessageAsync(string.Format("Sad to see you leave {0}. Here, I'll remove that role from you.", gameRoles[0].Name));

                break;

            default:
                await((IGuildUser)context.User).RemoveRolesAsync(gameRoles);
                await context.Channel.SendMessageAsync("Well, I've removed those games from your role list.");

                break;
            }
        }
예제 #4
0
 private async void UpdateStatus(object sender, ElapsedEventArgs args)
 {
     if (!KrispyGenerator.Odds(4))
     {
         return;
     }
     var result = new KrispyStatusLine();
     await Client.SetGameAsync(result.Status, null, result.Type);
 }
예제 #5
0
        private async Task CheckMessage(SocketMessage msg)
        {
            if (!(msg is SocketUserMessage userMsg))
            {
                return;
            }

            await KrispyCommands.MonitorMessages(msg);

            int  mentionPos = 0, charPos = 0;
            bool passMention = false, passChar = false;

            if (userMsg.HasMentionPrefix(Client.CurrentUser, ref mentionPos))
            {
                passMention = true;
            }
            else if (userMsg.HasCharPrefix('$', ref charPos))
            {
                passChar = true;
            }

            if (passMention || passChar)
            {
                var pos = passMention ? mentionPos : charPos;
                if (await KrispyCommands.Fun(Client, msg, pos))
                {
                    return;
                }
                var context = new SocketCommandContext(Client, userMsg);
                var result  = await Commands.ExecuteAsync(context, pos, Services);

                if (!result.IsSuccess)
                {
                    if (result.Error == CommandError.UnknownCommand)
                    {
                        var chosenLine = KrispyGenerator.PickLine(KrispyLines.Unknown);
                        if (chosenLine.Contains("{0}"))
                        {
                            chosenLine =
                                string.Format(chosenLine, KrispyNickname.FirstName(((IGuildUser)msg.Author).Nickname));
                        }
                        await context.Channel.SendMessageAsync(chosenLine);
                    }
                    else
                    {
                        await context.Channel.SendMessageAsync(
                            "Hehehe... We've hit an error!\n```\n" + result.ErrorReason + "\n```");
                    }
                }
            }
        }
        public async Task CleanContributions(SocketUser user)
        {
            if (!Context.User.IsAdmin())
            {
                await ReplyAsync("Sorry, only admins can use this command.");

                return;
            }
            if (!Profiles.ContainsKey(user.Id))
            {
                await ReplyAsync("I couldn't find the user you were talking about :(");
            }
            else
            {
                Profiles.Remove(user.Id);
                await ReplyAsync("I removed all their contributions " + KrispyGenerator.PickLine(KrispyLines.Emoticon));
            }
        }
예제 #7
0
        public async Task NewNickname([Remainder] string nickname)
        {
            var user          = (IGuildUser)Context.User;
            var fullNickname  = user.Nickname;
            var firstName     = fullNickname.Substring(0, fullNickname.IndexOf('|')).Trim();
            var newNickname   = KrispyLines.CapitalizeAll(nickname);
            var finalNickname = firstName + " | " + newNickname;

            if (finalNickname.Length > 32)
            {
                await ReplyAsync(
                    "That's a long nickname. Try to keep it under " + (32 - (firstName.Length + 3)) + " characters."
                    );
            }
            else
            {
                await user.ModifyAsync(x => { x.Nickname = finalNickname; });
                await ReplyAsync("I changed your nickname " + KrispyGenerator.PickLine(KrispyLines.Emoticon));
            }
        }
예제 #8
0
        public async Task Reschedule([Remainder] string schedule)
        {
            schedule = schedule.ToLower();
            var roles     = FindRoles(schedule, Context.Guild);
            var guildUser = (IGuildUser)Context.User;

            switch (roles.Count)
            {
            case 0:
                await ReplyAsync(KrispyGenerator.PickLine(KrispyLines.Disappointed)
                                 + " If you want to clear your schedule use $schedule-clear.");

                break;

            case 1:
                await guildUser.AddRolesAsync(roles);

                await Context.Channel.SendMessageAsync("You're taking " + roles[0].Name + "? I've added that role for you.");

                break;

            default:
                await RemoveScheduleRoles(Context.Guild, guildUser);

                await guildUser.AddRolesAsync(roles);

                var response = new StringBuilder("Here's your new schedule " +
                                                 KrispyGenerator.PickLine(KrispyLines.Emoticon) + "\n```\n");
                foreach (var role in roles)
                {
                    response.Append("\t- " + role.Name + "\n");
                }
                response.Append("```");
                await ReplyAsync(response.ToString());

                break;
            }
        }
예제 #9
0
        public static async Task <bool> Fun(DiscordSocketClient client, SocketMessage msg, int msgLoc)
        {
            var text       = msg.ToString().ToLower().Substring(msgLoc);
            var components = text.Split(" ");

            if (components.Contains("hi"))
            {
                await msg.Channel.SendMessageAsync("Hello " + KrispyGenerator.PickLine(KrispyLines.Emoticon));
            }
            else if (components.Contains("hello"))
            {
                await msg.Channel.SendMessageAsync("Hi " + KrispyGenerator.PickLine(KrispyLines.Emoticon));
            }
            else if (text.Contains("what") && (components.Contains("time") ||
                                               components.Contains("day") ||
                                               components.Contains("date")))
            {
                await msg.Channel.SendMessageAsync("It is February " +
                                                   (int)(DateTime.Now - new DateTime(2018, 2, 1)).TotalDays +
                                                   ", 2018.");
            }
            else if (text.Contains("what") && components.Contains("love"))
            {
                await msg.Channel.SendMessageAsync("Baby don't hurt me.");
            }
            else if (components.Contains("donut") || components.Contains("doughnut"))
            {
                await msg.Channel.SendMessageAsync(":doughnut:");
            }
            else if (components.Contains("mispell"))
            {
                await msg.Channel.SendMessageAsync("I mean... that's how I spelled it. That's not actually right.");
            }
            else if (components.Contains("misspell"))
            {
                await msg.Channel.SendMessageAsync("Correct! Good job... Here's a doughnut: :doughnut:.");
            }
            else if (components.Contains("inspire"))
            {
                string inspiroBotUrl;
                var    request = (HttpWebRequest)WebRequest.Create("http://inspirobot.me/api?generate=true&oy=vey");
                using (var response = (HttpWebResponse)request.GetResponse())
                    using (var stream = response.GetResponseStream())
                        using (var reader = new StreamReader(stream)) {
                            inspiroBotUrl = reader.ReadToEnd();
                        }

                await msg.Channel.SendMessageAsync(inspiroBotUrl);
            }
            else if (components.Contains("bitch"))
            {
                await msg.Channel.SendMessageAsync("Look who's talking.");
            }
            else if (components.Contains("ur") && components.Contains("mom") && components.Contains("gay"))
            {
                await msg.Channel.SendMessageAsync("no u");
            }
            else if (KrispySchedule.FindRoleIds(components[0]).Count == 1)
            {
                var role = KrispySchedule.FindRoles(components[0],
                                                    (SocketGuild)((IGuildChannel)msg.Channel).Guild)[0];
                await((IGuildUser)msg.Author).AddRoleAsync(role);
                await msg.Channel.SendMessageAsync("Added " + role.Name + " to your schedule "
                                                   + KrispyGenerator.PickLine(KrispyLines.Emoticon));
            }
            else
            {
                return(false);
            }

            return(true);
        }
예제 #10
0
 public Task ThrowError()
 {
     throw new Exception(KrispyGenerator.GenerateBeeps());
 }
예제 #11
0
 public async Task Dummy([Remainder] string text)
 {
     Console.WriteLine(text);
     await ReplyAsync("Ditto " + KrispyGenerator.PickLine(KrispyLines.Emoticon));
 }