Exemplo n.º 1
0
        public DiscordBot()
        {
            client = new DiscordClient(input =>
            {
                input.LogLevel   = LogSeverity.Info;
                input.LogHandler = Log;
            });



            client.UsingCommands(input =>
            {
                input.PrefixChar         = '!';
                input.AllowMentionPrefix = true;
            });


            commands = client.GetService <CommandService>();


            commands.CreateCommand("teste").Do(async(e) =>
            {
                await e.Channel.SendTTSMessage("Testando o bot putos");
            });

            client.ExecuteAndWait(async() =>
            {
                await client.Connect("MzA5MTU0MTYxMzA2NTAxMTIw.C-rRyA.j7qCtBcLeaO6QHj7YIlPU2nqIy8", TokenType.Bot);
            }
                                  );
        }
Exemplo n.º 2
0
        public Magic8BallBot()
        {
            client = new DiscordClient(input =>
            {
                input.LogLevel   = LogSeverity.Info;
                input.LogHandler = Log;
            });

            client.UsingCommands(input =>
            {
                input.PrefixChar         = '?';
                input.AllowMentionPrefix = true;
            });

            commands = client.GetService <CommandService>();

            // Commands
            commands.CreateCommand("#")
            .Parameter("question", ParameterType.Unparsed)
            .Do(async(e) =>
            {
                await(e.Channel.SendMessage(getResponse(e.User.Name, getRand())));
            });

            client.ExecuteAndWait(async() =>
            {
                await(client.Connect("MzA3NTQ1MjgzMjIxNTIwMzg0.C-T3dw.JpyCX1gE7HhmHKtxqpkWeRt5QL8", TokenType.Bot));
            });
        }
Exemplo n.º 3
0
        public DiscordBot()
        {
            client = new DiscordClient(input =>
            {
                input.LogLevel   = LogSeverity.Info;
                input.LogHandler = Log;
            });

            client.UsingCommands(input =>
            {
                input.PrefixChar         = '!';
                input.AllowMentionPrefix = true;
            });

            commands = client.GetService <CommandService>();

            commands.CreateCommand("Hello").Do(async(e) =>
            {
                await e.Channel.SendMessage("World!");
            });

            client.ExecuteAndWait(async() =>
            {
                await client.Connect("MzEzNTA4NjU4ODkxOTgwODAx.C_qpZQ.vgapRRHkXl4CobCOhsO45svdSzk", TokenType.Bot);
            });
        }
Exemplo n.º 4
0
 private void RegisterMemeCommand()
 {
     commands.CreateCommand("meme")
     .Do(async(e) =>
     {
         int randomMemeIndex = rand.Next(freshestMemes.Length);
         string memeToPost   = freshestMemes[randomMemeIndex];
         await e.Channel.SendFile(memeToPost);
     });
 }
Exemplo n.º 5
0
 private void SendRoastCommand()
 {
     commands.CreateCommand("roast")
         .Do(async (e) =>
         {
             int randomRoastIndex = rand.Next(roasts.Length);
             string roastToChat = roasts[randomRoastIndex];
             await e.Channel.SendTTSMessage(roastToChat);
         });
 }
Exemplo n.º 6
0
        public static void Init()
        {
            GameCommandService.CreateCommand("PaperRockScissor")
            .Description("Challenge someone to a Paper-Rock-Scissor game")
            .Parameter("users", ParameterType.Unparsed)
            .Alias(new string[] { "battle", "game" })
            .Do(async(e) =>
            {
                await e.Message.Delete();
                if (e.Message.IsMentioningMe() && e.Message.MentionedUsers.Count() == 1)
                {
                    StartNewGame(e.Channel, e.User, true);
                    return;
                }
                if (e.Message.IsMentioningMe() && e.Message.MentionedUsers.Count() == 2)
                {
                    User opponent = e.Message.MentionedUsers.Where(user => user.Id != Bot.Client.CurrentUser.Id).First();
                    StartNewGame(e.Channel, opponent, true);
                    return;
                }
                if (e.Message.MentionedUsers.Count() == 0 ||
                    e.Message.MentionedUsers.Count() >= 3 ||
                    e.Channel.IsPrivate ||
                    e.Message.MentionedUsers.First() == e.User ||
                    (e.Message.MentionedUsers.Count() == 2 && e.Message.MentionedUsers.ElementAt(0) == e.Message.MentionedUsers.ElementAt(1)))
                {
                    return;
                }
                if (e.Message.MentionedUsers.Count() == 1)
                {
                    StartNewGame(e.Channel, e.User, e.Message.MentionedUsers.First(), true);
                }
                if (e.Message.MentionedUsers.Count() == 2)
                {
                    StartNewGame(e.Channel, e.Message.MentionedUsers.ElementAt(0), e.Message.MentionedUsers.ElementAt(1), false);
                }
            });

            GameCommandService.CreateCommand("Scissors")
            .Description("Scrissors-choice")
            .Hide()
            .Alias(new string[] { "scissors, s" })
            .Do((e) =>
            {
                var game = GetGameOfUser(e.User.Id);
                if (game == null)
                {
                    return;
                }

                if (game.SetPlayerChoice(e.User, PRSGame.Player.Choice.Scissors).Result)
                {
                    FinishBattle(game);
                }
                else if (e.Channel == game.PublicChannel)
                {
                    game.PublicChannel.SendMessage("Ich glaube, es wäre für dich von Vorteil, wenn du mir deine Wahl im privaten Chat schreibst, " + e.User.Mention + " :thinking:");
                }
            });

            GameCommandService.CreateCommand("Rock")
            .Description("Rock-choice")
            .Hide()
            .Alias(new string[] { "rock, r" })
            .Do((e) =>
            {
                var game = GetGameOfUser(e.User.Id);
                if (game == null)
                {
                    return;
                }

                if (game.SetPlayerChoice(e.User, PRSGame.Player.Choice.Rock).Result)
                {
                    FinishBattle(game);
                }
                else if (e.Channel == game.PublicChannel)
                {
                    game.PublicChannel.SendMessage("Ich glaube, es wäre für dich von Vorteil, wenn du mir deine Wahl im privaten Chat schreibst, " + e.User.Mention + " :thinking:");
                }
            });

            GameCommandService.CreateCommand("Paper")
            .Description("Paper-choice")
            .Hide()
            .Alias(new string[] { "paper, p" })
            .Do((e) =>
            {
                var game = GetGameOfUser(e.User.Id);
                if (game == null)
                {
                    return;
                }

                if (game.SetPlayerChoice(e.User, PRSGame.Player.Choice.Paper).Result)
                {
                    FinishBattle(game);
                }
                else if (e.Channel == game.PublicChannel)
                {
                    game.PublicChannel.SendMessage("Ich glaube, es wäre für dich von Vorteil, wenn du mir deine Wahl im privaten Chat schreibst, " + e.User.Mention + " :thinking:");
                }
            });
        }
Exemplo n.º 7
0
        public MyBot()
        {
            /* init */
            client = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

            client.UsingCommands(input =>
            {
                input.PrefixChar         = '!';
                input.AllowMentionPrefix = true;
            });
            commands = client.GetService <CommandService>();
            /* init */

            /*
             *  Default info
             */
            commands.CreateCommand("hello").Do(async(e) =>
            {
                await e.Channel.SendMessage("こんにちは " + e.User.NicknameMention);
            });

            commands.CreateCommand("千川ちひろ").Alias("help").Do(async(e) =>
            {
                await help(e);
                //await e.Channel.SendMessage("rockon590が大好き^_^");
            });


            commands.CreateCommand("admin").Parameter("message", ParameterType.Multiple).Do(async(e) =>
            {
                string jsonstr = "";
                try { jsonstr = File.ReadAllText("../../../Certificate.json"); }
                catch
                {
                    Console.WriteLine("ERROR: 沒有找到" + "Certificate.json");
                    Console.ReadKey();
                }

                /* discordBot Token */
                JObject jsonobj = JObject.Parse(jsonstr);
                string owner    = jsonobj.GetValue("owner").ToString();
                if (owner != null && owner.Equals(e.User.NicknameMention))
                {
                    if (e.Args.Length == 1)
                    {
                        if (e.Args[0].Equals("晚安"))
                        {
                            var eu_channel   = client.GetServer(293706623652724736).GetChannel(299934136448057365); // eu testlab
                            var nmw_channel  = client.GetServer(257033414576701442).GetChannel(295057576020934656); // nmw gambling
                            var lika_channel = client.GetServer(308898984200765450).GetChannel(308908235413389314); // lika gambling
                            await eu_channel.SendMessage("みなさん、おやすみなさい");
                            await nmw_channel.SendMessage("みなさん、おやすみなさい");
                            await lika_channel.SendMessage("みなさん、おやすみなさい");
                            Console.WriteLine("SUCCESS!");
                            Environment.Exit(0);
                        }
                    }
                }
            });



            /*
             *  End Default info
             */

            /*
             * Add feature
             */
            UserInfo();
            Draw.DrawCardCommand();
            Instrucions.SetInstrucions();
            Lots.DrawLotsCommand();
            DrawRank.DrawCardRankCommand();
            ;
            ;
            ;
            ;

            /*
             * End feature
             */


            /*
             * Discord bot login.
             * Need to put last line.
             */
            client.ExecuteAndWait(async() =>
            {
                // Get discordBot Token from json
                string jsonstr = "";
                try { jsonstr = File.ReadAllText("../../../Certificate.json"); }
                catch
                {
                    Console.WriteLine("ERROR: 沒有找到" + "Certificate.json");
                    Console.ReadLine();
                    return;
                }

                /* discordBot Token */
                JObject jsonobj        = JObject.Parse(jsonstr);
                string discordbotToken = jsonobj.GetValue("token").ToString();
                if (discordbotToken == "")
                {
                    Console.WriteLine("Please check your token from \"Certificate.json\" file");
                    Console.WriteLine("URL : https://discordapp.com/developers/applications/me");
                    Console.ReadLine();                     //Pause
                    return;
                }

                await client.Connect(discordbotToken, TokenType.Bot);
                client.SetGame(new Game(jsonobj.GetValue("game").ToString()));
            });
        }
Exemplo n.º 8
0
        public DiscordBot()
        {
            client = new DiscordClient(input =>
            {
                input.LogLevel   = LogSeverity.Info;
                input.LogHandler = Log;
            });



            client.UsingCommands(input => {
                input.PrefixChar         = '!';
                input.AllowMentionPrefix = true;
                input.HelpMode           = HelpMode.Public;
            });

            commands = client.GetService <CommandService>();

            commands.CreateCommand("Hello").Alias(new string[] { "hi", "sup" }).Do(async(e) =>
            {
                await e.Channel.SendMessage("World");
            });



            commands.CreateCommand("Niggah").Alias(new string[] { "yo", "homie" }).Do(async(e) =>
            {
                await e.Channel.SendMessage("N***a, please!");
            });

            commands.CreateCommand("announce").Parameter("message", ParameterType.Unparsed).Do(async(e) =>
            {
                await DoAnnouncement(e);
            });

            client.UserJoined += async(s, e) =>
            {
                var channel = e.Server.FindChannels("gay-mers", ChannelType.Text).FirstOrDefault();

                var user = e.User;

                await channel.SendTTSMessage(string.Format("{0} has joined the channel!", user.Name));
            };

            client.UserLeft += async(s, e) =>
            {
                var channel = e.Server.FindChannels("gay-mers", ChannelType.Text).FirstOrDefault();

                var user = e.User;

                await channel.SendTTSMessage(string.Format("{0} has left the channel", user.Name));
            };


            client.ExecuteAndWait(async() =>
            {
                await client.Connect("MTk3NDUzODUwNDY5MzM1MDUx.C2g1eg.SJtbmHXDhsIbxorIXjkxQV2VDLs", TokenType.Bot);
            });


            /* MULTITHREADED ADMIN PANEL*/
            commands.CreateCommand("adminpanel").Do((e) =>
            {
                AdminPanel = new Adminpanel(client, e);

                var thread = new Thread(OpenAdminPanel);

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            });
        }
Exemplo n.º 9
0
        public PaperRockScissors(Channel tChannel, User challengerUser, User adversaryUser, bool isChallenge, int minutesToGo = 5, string reason = "")
        {
            this.tChannel       = tChannel;
            this.challengerUser = challengerUser;
            this.adversaryUser  = adversaryUser;
            timeToGo            = new TimeSpan(0, minutesToGo, 0);
            this.reason         = reason;
            this.isChallenge    = isChallenge;
            SetupBattle();

            GameCommandService.CreateCommand("Scissors")
            .Description("Scrissors-choice")
            .Hide()
            .Alias(new string[] { "scissors, s" })
            .Do(async(e) =>
            {
                if (e.User.Id == challengerUser.Id)
                {
                    challengerChoice = Choice.Scissors;
                    CheckBattle(true);
                    await e.User.SendMessage("Your choice is scissors.");
                }
                if (e.User.Id == adversaryUser.Id)
                {
                    adversaryChoice = Choice.Scissors;
                    CheckBattle(false);
                    await e.User.SendMessage("Your choice is scissors.");
                }
            });

            GameCommandService.CreateCommand("Rock")
            .Description("Rock-choice")
            .Hide()
            .Alias(new string[] { "rock, r" })
            .Do(async(e) =>
            {
                if (e.User.Id == challengerUser.Id)
                {
                    challengerChoice = Choice.Rock;
                    CheckBattle(true);
                    await e.User.SendMessage("Your choice is rock.");
                }
                if (e.User.Id == adversaryUser.Id)
                {
                    adversaryChoice = Choice.Rock;
                    CheckBattle(false);
                    await e.User.SendMessage("Your choice is rock.");
                }
            });

            GameCommandService.CreateCommand("Paper")
            .Description("Paper-choice")
            .Hide()
            .Alias(new string[] { "paper, p" })
            .Do(async(e) =>
            {
                if (e.User.Id == challengerUser.Id)
                {
                    challengerChoice = Choice.Paper;
                    CheckBattle(true);
                    await e.User.SendMessage("Your choice is paper.");
                }
                if (e.User.Id == adversaryUser.Id)
                {
                    adversaryChoice = Choice.Paper;
                    CheckBattle(false);
                    await e.User.SendMessage("Your choice is paper.");
                }
            });
        }
Exemplo n.º 10
0
        public void CreateCommand()
        {
            CommandService cService = discordBot.GetService <CommandService>();

            #region Ping Command
            cService.CreateCommand("ping")
            .Description("Return ping")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Pong");
            });
            #endregion

            #region Hello Command
            cService.CreateCommand("Hello")
            .Description("Return the user parameter")
            .Parameter("user", ParameterType.Unparsed)
            .Do(async(e) =>
            {
                string userArg = $"{e.GetArg("user")}";

                string message = $"{e.User.NicknameMention} says hello to {userArg}";
                await e.Channel.SendMessage(message);
            });
            #endregion

            #region HelloDoubleMention Command
            cService.CreateCommand("Hello2you")
            .Description("Say hello to an other user, the username entered must have the same characters")
            .Parameter("user", ParameterType.Unparsed)
            .Do(async(e) =>
            {
                User user;

                user = e.Server.Users.Where(x => x.Name.ToLower().Equals(e.GetArg("user").ToLower())).Select(x => x).First();

                await e.Channel.SendMessage($"{e.User.NicknameMention} says Hello to {user.NicknameMention}");
            });
            #endregion

            #region Roll Command
            cService.CreateGroup("roll", cg =>
            {
                #region 1d4
                cg.CreateCommand("1d4")
                .Description("Roll 1d4")
                .Do(async(e) =>
                {
                    int d = r.Next(1, 5);

                    await e.Channel.SendMessage($"{e.User.NicknameMention} rolled {d}");
                });
                #endregion

                #region 1d6
                cg.CreateCommand("1d6")
                .Description("Roll 1d6")
                .Do(async(e) =>
                {
                    int d = r.Next(1, 7);

                    await e.Channel.SendMessage($"{e.User.NicknameMention} rolled {d}");
                });
                #endregion

                #region 1d12
                cg.CreateCommand("1d12")
                .Description("Roll 1d12")
                .Do(async(e) =>
                {
                    int d = r.Next(1, 13);

                    await e.Channel.SendMessage($"{e.User.NicknameMention} rolled {d}");
                });
                #endregion

                #region 1d20
                cg.CreateCommand("1d20")
                .Description("Roll 1d20")
                .Do(async(e) =>
                {
                    int d = r.Next(1, 21);

                    await e.Channel.SendMessage($"{e.User.NicknameMention} rolled {d}");
                });
                #endregion

                #region Custom
                cg.CreateCommand("custom")
                .Parameter("qtyDice", ParameterType.Required)
                .Parameter("sizeDice", ParameterType.Required)
                .Description("Make a custom dice roll ~roll custom <qtyDice> <sizeDice>")
                .Do(async(e) =>
                {
                    int qtyDice  = Convert.ToInt32(e.GetArg("qtyDice"));
                    int sizeDice = Convert.ToInt32(e.GetArg("sizeDice"));

                    int d = 0;
                    for (int i = 0; i < qtyDice; i++)
                    {
                        d += r.Next(1, sizeDice + 1);
                    }

                    await e.Channel.SendMessage($"{e.User.NicknameMention} rolled {qtyDice}d{sizeDice} and got {d}");
                });
                #endregion
            });

            #endregion

            #region Credit Command
            cService.CreateCommand("Info")
            .Description("Try it!")
            .Do(async(e) =>
            {
                Console.WriteLine($"[COMMAND]  [{e.User.Name}]  The CREDIT command was used.");
                await e.Channel.SendMessage(@"Iluvatar's Super Bot was coded by Iluvatar/Samuel Reid
You can install it on your server using this link : https://discordapp.com/oauth2/authorize?&client_id=198229043127123970&scope=bot&permissions=268528663
OR
The bot can be found at : https://github.com/IluvatarTheReal/IluvatarSuperBot");
            });
            #endregion

            #region Role Command
            cService.CreateGroup("role", cg =>
            {
                #region List
                cg.CreateCommand("list")
                .Do(async(e) =>
                {
                    IEnumerable <Role> roles = e.Server.Roles.OrderByDescending(r => r.Position);
                    string message           = $"The role in this server are :\n";
                    foreach (var r in roles)
                    {
                        message += $"{r.Mention}\n";
                    }
                    await e.Channel.SendMessage(message);
                });
                #endregion

                #region UserIn
                cg.CreateCommand("userin")
                .Description("List all user with the chosen role")
                .Parameter("role", ParameterType.Unparsed)
                .Do(async(e) =>
                {
                    Role role;
                    IEnumerable <User> users;

                    role  = BasicQuery.GetRole(e, "role");
                    users = e.Server.Users.Where(x => x.Roles.Contains(role));

                    string message = $"The {role.Mention} are :\n";
                    foreach (var u in users)
                    {
                        message += $"{u.NicknameMention}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion

                #region Me
                cg.CreateCommand("me")
                .Do(async(e) =>
                {
                    IEnumerable <Role> roles = e.User.Roles.OrderByDescending(r => r.Position);

                    string message = $"{e.User.NicknameMention} roles are :\n";
                    foreach (var r in roles)
                    {
                        message += $"{r.Mention}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion

                #region User
                cg.CreateCommand("user")
                .Parameter("user", ParameterType.Unparsed)
                .Do(async(e) =>
                {
                    User user = BasicQuery.GetUser(e, "user");

                    IEnumerable <Role> roles = user.Roles.OrderByDescending(r => r.Position);

                    string message = $"{user.NicknameMention} roles are :\n";
                    foreach (var r in roles)
                    {
                        message += $"{r.Mention}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion
            });
            #endregion

            #region Channel Command
            cService.CreateGroup("channel", cg =>
            {
                #region Clear
                cg.CreateCommand("clear")
                .MinPermissions((int)PermissionLevel.ChannelModerator)
                .Description("Clear the channel removing all message sent since the bot went online.")
                .Do(async(e) =>
                {
                    await e.Channel.DeleteMessages(e.Channel.Messages.ToArray());
                });
                #endregion

                #region Topic
                cg.CreateCommand("topic")
                .Description("Return channel's topic")
                .Do(async(e) =>
                {
                    await e.Channel.SendMessage(e.Channel.Topic);
                });
                #endregion
            });
            #endregion

            #region Permission Command
            cService.CreateGroup("permission", cg =>
            {
                #region Me
                cg.CreateCommand("me")
                .Description("Return your permission level on this channel.")
                .Do(async(e) =>
                {
                    PermissionLevel perm = GetPermissions(e.User, e.Channel);

                    await e.Channel.SendMessage(BasicQuery.PermissionNameUser(e.User, perm));
                });
                #endregion

                #region List
                cg.CreateCommand("list")
                .Do(async(e) =>
                {
                    await e.Channel.SendMessage("6 - BOT OWNER\n5 - SERVER OWNER\n4 - SERVER ADMIN\n3 - SERVER MODERATOR\n2 - CHANNEL ADMIN\n1 - CHANNEL MODERATOR\n0 - USER");
                });
                #endregion

                #region User
                cg.CreateCommand("user")
                .Description("Return the permission level of an other user on this channel.")
                .Parameter("user", ParameterType.Unparsed)
                .Do(async(e) =>
                {
                    User user            = BasicQuery.GetUser(e, "user");
                    PermissionLevel perm = GetPermissions(user, e.Channel);

                    await e.Channel.SendMessage(BasicQuery.PermissionNameUser(user, perm));
                });
                #endregion
            });
            #endregion

            #region Server Command
            cService.CreateGroup("server", cg =>
            {
                #region Kick
                //TODO : Kick Command
                #endregion

                #region Ban
                //TODO : Ban Command
                #endregion

                #region Shutdown
                cg.CreateCommand("shutdown")
                .MinPermissions((int)PermissionLevel.BotOwner)
                .Description("Shutdown the bot")
                .Do(async(e) =>
                {
                    Environment.Exit(0);
                });
                #endregion
            });
            #endregion

            #region Unassigned Search Command
            cService.CreateGroup("search", cg =>
            {
                #region User
                cg.CreateCommand("user")
                .Parameter("user", ParameterType.Unparsed)
                .Do(async(e) =>
                {
                    IEnumerable <User> users = BasicQuery.SearchUsers(e, "user");

                    string message = $"{e.User.NicknameMention}, your research returned {users.Count()} result(s)\n";
                    foreach (var u in users)
                    {
                        message += $"{u.Name}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion

                #region Role
                cg.CreateCommand("role")
                .Parameter("role", ParameterType.Unparsed)
                .Do(async(e) =>
                {
                    IEnumerable <Role> roles = BasicQuery.SearchRoles(e, "role");

                    string message = $"{e.User.NicknameMention}, your research returned {roles.Count()} result(s)\n";
                    foreach (var r in roles)
                    {
                        message += $"{r.Name}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion
            });
            #endregion

            #region Music Command
            cService.CreateGroup("music", cg =>
            {
                #region Start
                cg.CreateCommand("start")
                .Parameter("tune#", ParameterType.Unparsed)
                .Description("Music command is NOT fully implemented yet.")
                .Do(async(e) =>
                {
                    //Channel voiceChannel = discordBot.FindServers("Bot Music").FirstOrDefault().VoiceChannels.FirstOrDefault();
                    voiceChannel = e.Server.VoiceChannels.Where(c => c.Name.ToLower().Contains(("Bot Music").ToLower())).Select(x => x).First();
                    var aService = await discordBot.GetService <AudioService>()
                                   .Join(voiceChannel);
                    string filePath = $"Music\\{e.GetArg("tune#")}";

                    await e.Channel.SendMessage("Music started on voice channel *Bot Music*");
                    Audio.StartMusic(filePath, discordBot, voiceChannel, aService);
                    await e.Channel.SendMessage("Music ended on voice channel *Bot Music*");

                    await discordBot.GetService <AudioService>()
                    .Leave(voiceChannel);
                    Audio.StopPlaying();
                });
                #endregion

                #region Stop
                cg.CreateCommand("stop")
                .Description("Music command is NOT fully implemented yet.")
                .Do(async(e) =>
                {
                    voiceChannel = e.Server.VoiceChannels.Where(c => c.Name.ToLower().Contains(("Bot Music").ToLower())).Select(x => x).First();
                    await discordBot.GetService <AudioService>()
                    .Leave(voiceChannel);

                    Audio.StopPlaying();

                    await e.Channel.SendMessage("Music was stopped on channel *Bot Music*");
                });
                #endregion

                #region Search
                cg.CreateCommand("search")
                .Parameter("song", ParameterType.Unparsed)
                .Description("Music command is NOT fully implemented yet.")
                .Do(async(e) =>
                {
                    IEnumerable <string> songs = BasicQuery.GetSongs().Where(s => s.ToLower().Contains(e.GetArg("song").ToLower()));

                    string message = $"{e.User.NicknameMention}, your research returned {songs.Count()} result(s)\n";
                    foreach (var s in songs)
                    {
                        message += $"{s}\n";
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion

                #region List
                cg.CreateCommand("list")
                .Description("Music command is NOT fully implemented yet.")
                .Do(async(e) =>
                {
                    IEnumerable <string> songs = BasicQuery.GetSongs();

                    string message = $"{e.User.NicknameMention}, there are {songs.Count()} song(s) available\n";
                    foreach (var s in songs)
                    {
                        if (s != "nothing.bk")
                        {
                            message += $"{s}\n";
                        }
                    }

                    await e.Channel.SendMessage(message);
                });
                #endregion
            });

            #endregion

            //Link pour installer https://discordapp.com/oauth2/authorize?&client_id=198229043127123970&scope=bot&permissions=268528663
        }
Exemplo n.º 11
0
        public EvilBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

            discord.UsingCommands(x =>
            {
                x.PrefixChar         = '`';
                x.AllowMentionPrefix = true;
            });

            CommandService commands;

            commands = discord.GetService <CommandService>();



            //---------------------------------------Show me what you got---------------------------------

            freshestMemes = new string[]
            {
                "mem/test.jpg",
                "mem/GetInBich.jpg",
                "mem/rompers.jpg",
                "mem/dwk.jpg",
                "mem/abortion.jpg",
                "mem/prayer.jpg",
                "mem/sasuke_patrick.jpg"
            };

            commands.CreateCommand("show me what you got")
            .Do(async(e) =>
            {
                Random rand = new Random();
                int temp    = rand.Next(0, freshestMemes.Length);
                await e.Channel.SendMessage("Here is meme #" + temp + "/" + freshestMemes.Length);
                await e.Channel.SendFile(freshestMemes[temp]);
            });

            //----------------------------------Text Commands------------------------------

            commands.CreateCommand("hello")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Hi Bitch!");
            });

            commands.CreateCommand("help")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Do I look like the kind of bot that gives help?");
            });
            commands.CreateCommand("help")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Do I look like the kind of bot that gives help?");
            });

            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MzE4NTk4NzE4MTYzMjU1Mjk4.DDISOw.s3-TBtxlDop7KUMx3N7O6s2rMAY", TokenType.Bot);
            });
        }