예제 #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("Hello").Do(async(e) =>
            {
                await e.Channel.SendMessage("World!");
            });

            client.ExecuteAndWait(async() =>
            {
                await client.Connect("MzEzNTA4NjU4ODkxOTgwODAx.C_qpZQ.vgapRRHkXl4CobCOhsO45svdSzk", TokenType.Bot);
            });
        }
예제 #2
0
        public aBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

            //command instigator
            discord.UsingCommands(x =>
            {
                x.PrefixChar = '/';
                x.HelpMode   = HelpMode.Public;
            });

            //command service variable
            var commands = discord.GetService <CommandService>();

            //hello command
            commands.CreateCommand("hello")
            .Alias("hi")
            .Description("Says hello back.")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Hi");
            });

            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MjQ3NDkwNTc0MTkyNDc2MTYx.CwqEfw.GySquE25grhI_WXXbx1mXD5_RHI", TokenType.Bot);
            });
        }
예제 #3
0
        public MyBot()
        {
            rand = new Random();

            freshestMemes = new string[]
            {
                "memes/meme1.jpg",
                "memes/meme2.jpg",
                "memes/meme3.jpg",
                "memes/meme4.jpg"
            };

            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

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

            commands = discord.GetService <CommandService>();

            RegisterMemeCommand();

            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MzM0OTg0ODEyNjM5MDI3MjEw.DEjWvw.19MwXHtk9b7vlcyprzZQCnmFwH0", TokenType.Bot);
            });
        }
예제 #4
0
        public void Start()
        {
            Client = new DiscordClient(x =>
            {
                x.AppName    = "DiscordBot";
                x.AppUrl     = "";
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = ClientLog;
            });

            Client.UsingCommands(x =>
            {
                x.PrefixChar         = char.Parse("!");
                x.AllowMentionPrefix = true;
                x.HelpMode           = HelpMode.Public;
            });

            string Token = "MjgyOTkwMzg4NjkwNTUwNzg1.C4vVxg.5mGFuAKxUkEBknIRfZDBfD4Y_-U";

            CreateCommands();

            Client.ExecuteAndWait(async() =>
            {
                await Client.Connect(Token, TokenType.Bot);
            });
        }
예제 #5
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));
            });
        }
예제 #6
0
        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

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

            var commands = discord.GetService <CommandService>();

            commands.CreateCommand("time").Parameter("params", ParameterType.Multiple)
            .Do(async(e) =>
            {
                await e.Channel.SendMessage(pickMethod(e));
            });


            commands.CreateCommand("test").Parameter("params", ParameterType.Multiple)
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("this is a test");
            });


            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MzAyNjM0MTg0MzQ0NjAwNTg2.C9QI6g.WMRycgkDKXIauFYRiQz3ovC95AU", TokenType.Bot);
            });
        }
예제 #7
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);
            }
                                  );
        }
예제 #8
0
        //String[] ArgText = {
        //"What in Davy Jones’ locker did ye just bark at me, ye scurvy bilgerat? I’ll have ye know I be the meanest cutthroat on the seven seas,",
        //"and I’ve led numerous raids on fishing villages, and raped over 300 wenches.I be trained in hit-and-run pillaging and be the deadliest with a pistol of all the captains",
        //"on the high seas.Ye be nothing to me but another source o’ swag.I’ll have yer guts for garters and keel haul ye like never been done before, hear me true. You think ye can hide behind",
        //"your newfangled computing device? Think twice on that, scallywag. As we parley I be contacting my secret network o’ pirates across the sea and yer port is being tracked right now",
        //"so ye better prepare for the typhoon, weevil. The kind o’ monsoon that’ll wipe ye off the map.You’re sharkbait, fool.I can sail anywhere, in any waters, and can kill ye",
        //"in o’er seven hundred ways, and that be just with me hook and fist.Not only do I be top o’ the line with a cutlass, but I have an entire pirate fleet at my beck and call and I’ll damned",
        //"sure use it all to wipe yer arse off o’ the world, ye dog. If only ye had had the foresight to know what devilish wrath your jibe was about to incur, ye might have belayed the comment.",
        //"But ye couldn’t, ye didn’t, and now ye’ll pay the ultimate toll, you buffoon. I’ll shit fury all over ye and ye’ll drown in the depths o’ it.You’re fish food now, lad."
        //};

        //String[] DoItText = {
        //"DO IT, just DO IT! Don’t let your dreams be dreams. Yesterday, you said tomorrow. So just. DO IT! Make. your dreams. COME TRUE! Just… do it! Some people dream of success,",
        //"while you’re gonna wake up and work HARD at it! NOTHING IS IMPOSSIBLE!You should get to the point where anyone else would quit, and you’re not gonna stop there.",
        //"NO! What are you waiting for? … DO IT! Just… DO IT! Yes you can! Just do it! If you’re tired of starting over, stop. giving. up."
        // };

        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

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

            commands = discord.GetService <CommandService>();

            //Used to bypass the need for a prefix and will listen for key words as commands
            ListenForCommands();
            //Says in TTS who joins a Voice Channel
            AnnounceVCJoin();


            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MzAzMjY2MTY4MDMzMTE2MTYz.C9VrTg.GItnjGeV-JRpg3qG2OKC9JpDqTw", TokenType.Bot);
            });
        }
예제 #9
0
        static void Main(string[] args)
        {
            bot.MessageReceived += Bot_MessageReceived;

            bot.ExecuteAndWait(
                async
                    () =>
            {
                //Connect to the Discord server using our email and password
                await bot.Connect("MjE4ODE4NTc2NzI1OTY2ODUx.CqM59Q.f_Hp2-_NVF0KVq2kBu2_dEezpvo");
            });
        }
예제 #10
0
        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });

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

            var commands = discord.GetService <CommandService>();

            commands.CreateCommand("hello")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Hi I am a bot");
            });

            commands.CreateCommand("info")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("I am written in C#");
            });

            commands.CreateCommand("anime")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("F**K ANIME");
            });

            /*commands.CreateCommand("sound")
             * .Do((e) =>
             * {
             *     Console.WriteLine("Some Audio");
             *     SendAudio(AppDomain.CurrentDomain.BaseDirectory + "\\test.mp3");
             * });
             */

            //var voiceChannel = discord.FindServers("4Head Kappa EleGiggle").FirstOrDefault().VoiceChannels.FirstOrDefault();

            //IAudioClient.Join(Channel);


            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MjgyNjE2NDMyODY3NjcyMDc0.C4t_5Q.mRorqG7vzxAITKEsAMQV7lSn1Fw", TokenType.Bot);
            });
        }
예제 #11
0
        public void startBot()
        {
            bot.MessageReceived += Bot_MessageReceived;


            bot.ExecuteAndWait(
                async
                    () =>
            {
                //Connect to the Discord server using our email and password
                await bot.Connect("Bot MjE4ODE4NTc2NzI1OTY2ODUx.CsU4Zw.upIHYCw7ARcSCwtDE1AYLFsjA38");     // Serene BOT
                //await bot.Connect("Bot MjE4ODE4NTc2NzI1OTY2ODUx.CsU4Zw.upIHYCw7ARcSCwtDE1AYLFsjA38"); // DEBUG: Test BOT
            });
        }
예제 #12
0
        void Start()
        {
            bot = new DiscordClient(x =>
            {
                x.AppName    = "SharkBot";
                x.AppUrl     = "http://sharkbound.weebly.com/";
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = log;
            });

            bot.UsingCommands(x =>
            {
                x.PrefixChar         = cfg.CommandPrefix;
                x.AllowMentionPrefix = true;
            });

            CreateCommands();

            bot.MessageReceived += async(s, e) =>
            {
                if (bot.Status == UserStatus.Offline ||
                    !e.Message.IsAuthor ||
                    e.Message.Text[0] == cfg.CommandPrefix)
                {
                    return;
                }

                var msg = $"{e.User.Name}: {e.Message.Text}";

                Logger.Log(msg, ConsoleColor.Red);
                await e.Channel.SendMessage(msg);

                await e.User.SendMessage($"You have posted \n\t'{e.Message.Text}' \nin channel \n\t{e.Channel.Name} \nat \n\t{DateTime.Now.ToString()}");
            };

            bot.ExecuteAndWait(async() =>
            {
                await bot.Connect(cfg.Token, TokenType.Bot);
            });
        }
예제 #13
0
        public DiscordBot()
        {
            bot = new DiscordClient();

            bot.MessageReceived += Bot_MessageReceived;
            alice.Initialize();

            bot.ExecuteAndWait(async() => {
                while (true)
                {
                    try
                    {
                        await bot.Connect("");
                        break;
                    }
                    catch
                    {
                        await Task.Delay(3000);
                    }
                }
            });
        }
예제 #14
0
        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = LogSeverity.Info;
                x.LogHandler = Log;
            });
            discord.UsingCommands(x =>
            {
                x.PrefixChar = '>';
            });
            var commands = discord.GetService <CommandService>();

            commands.CreateCommand("Hello")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("Different floats for different boats");
            });
            discord.MessageReceived += Discord_MessageReceived;
            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MjUyNjc1NDA5MjI3ODA4NzY4.CyJ8UA.Z9rAh5aO2jeMjhwNQt_T3q8RGWM", TokenType.Bot);
            });
        }
예제 #15
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();
            });
        }
예제 #16
0
        private void Start(string[] args)
        {
#if !DNXCORE50
            Console.Title = $"{AppName} (Discord.Net v{DiscordConfig.LibVersion})";
#endif

            GlobalSettings.Load();

            _client = new DiscordClient(x =>
            {
                x.AppName               = AppName;
                x.AppUrl                = AppUrl;
                x.MessageCacheSize      = 0;
                x.UsePermissionsCache   = true;
                x.EnablePreUpdateEvents = true;
                x.LogLevel              = LogSeverity.Verbose;
                x.LogHandler            = OnLogMessage;
            })
                      .UsingCommands(x =>
            {
                x.AllowMentionPrefix = true;
                x.HelpMode           = HelpMode.Public;
                x.ExecuteHandler     = OnCommandExecuted;
                x.ErrorHandler       = OnCommandError;
            })
                      .UsingModules()
                      //.UsingAudio(x =>
                      //{
                      //    x.Mode = AudioMode.Outgoing;
                      //    x.EnableMultiserver = true;
                      //    x.EnableEncryption = true;
                      //    x.Bitrate = AudioServiceConfig.MaxBitrate;
                      //    x.BufferLength = 10000;
                      //})
                      .UsingPermissionLevels(PermissionResolver);

            _client.AddService <SettingsService>();
            _client.AddService <HttpService>();

            _client.AddModule <AdminModule>("Admin", ModuleFilter.None);

            //_client.AddModule<ColorsModule>("Colors", ModuleFilter.None);
            _client.AddModule <FeedModule>("Feeds", ModuleFilter.None);
            _client.AddModule <GithubModule>("Repos", ModuleFilter.None);
            _client.AddModule <GImagesModule>("GImages", ModuleFilter.None);
            _client.AddModule <ModulesModule>("Modules", ModuleFilter.None);
            _client.AddModule <PublicModule>("Public", ModuleFilter.None);
            _client.AddModule <TwitchModule>("Twitch", ModuleFilter.None);
            _client.AddModule <SedModule>("SedModule", ModuleFilter.None);
            _client.AddModule <StatusModule>("Status", ModuleFilter.None);
            _client.AddModule <TwitchEmotesModule>("TwitchEmotes", ModuleFilter.None);
            _client.AddModule <TwitterModule>("TwitterModule", ModuleFilter.None);
            _client.AddModule <Waifu2xModule>("Waifu2xModule", ModuleFilter.None);
            //_client.AddModule(new ExecuteModule(env, exporter), "Execute", ModuleFilter.ServerWhitelist);

#if PRIVATE
            PrivateModules.Install(_client);
#endif

            //Convert this method to an async function and connect to the server
            //DiscordClient will automatically reconnect once we've established a connection, until then we loop on our end
            //Note: ExecuteAndWait is only needed for Console projects as Main can't be declared as async. UI/Web applications should *not* use this function.
            _client.ExecuteAndWait(async() =>
            {
                while (true)
                {
                    try
                    {
                        if (GlobalSettings.Discord.Token != null)
                        {
                            await _client.Connect(GlobalSettings.Discord.Token);
                        }
                        else
                        {
                            await _client.Connect(GlobalSettings.Discord.Email, GlobalSettings.Discord.Password);
                        }
                        //await _client.ClientAPI.Send(new Discord.API.Client.Rest.HealthRequest());
                        break;
                    }
                    catch (Exception ex)
                    {
                        _client.Log.Error($"Login Failed", ex);
                        await Task.Delay(_client.Config.FailedReconnectDelay);
                    }
                }
            });
        }
예제 #17
0
        public void Start()
        {
            _client = new DiscordClient();
            _client.MessageReceived += async(s, e) =>
            {
                if (!e.Message.IsAuthor)
                {
                    await e.Channel.SendMessage(e.Message.Text);
                }
            };
            _client.ExecuteAndWait(async() => {
                await _client.Connect("NDk5NzkzMzc5NTg5MzU3NTY4.DqBdxg.4YYspJPKqoHgYYeiyt7CoxXpv-E", TokenType.Bot);
            });
            //set bot prefix
            _client.UsingCommands(x => {
                x.PrefixChar = !; //find how to set 2 character as prefix ";/"
                x.HelpMode   = HelpMode.Public;
            });

            _client.GetService <CommandService>().CreateCommand("name") //Create a command
            .Alias(new string[] { "cmd", "command" })                   //add 2 aliases, so it can be run with ~cmd and ~command
            .Description("Command description.")                        //add description, it will be shown when ~help is used
            .Parameter("ParameterName", ParameterType.Required)         //as an argument, we have a person we want to greet
            .Do(async e =>
            {
                await e.Channel.SendMessage($"{e.User.Name} Command reply {e.GetArg("ParameterName")}");     //sends a message to channel with the given text
            });
            //TODO: Find how to create a Channel, learn more about Parameters and make this work!
            _client.GetService <CommandService>().CreateGroup("make", make =>
            {
                make.CreateCommand("textch")                //~make textch
                .Alias(new string[] { "textch" })
                .Description("Creates a new Text Channel.") // Not work yet
                .Parameter("???", ParameterType.Required)
                .Do(async e =>
                {
                    await e.Channel.SendMessage($"{e.User.Name} i donno wtf i'm doing {e.GetArg("???")}");
                });
                make.CreateCommand("voicech")                //~make voicech
                .Alias(new string[] { "voicech" })
                .Description("Creates a new Voice Channel.") // not work yet
                .Parameter("????", ParameterType.Required)
                .Do(async e =>
                {
                    await e.Channel.SendMessage($"{e.User.Name} change it later {e.GetArg("???")}");
                });
            });
            //exemple//we would run our commands with ~do greet X and ~do bye X
            _client.GetService <CommandService>().CreateGroup("do", cgb =>
            {
                cgb.CreateCommand("greet")
                .Alias(new string[] { "gr", "hi" })
                .Description("Greets a person.")
                .Parameter("GreetedPerson", ParameterType.Required)
                .Do(async e =>
                {
                    await e.Channel.SendMessage($"{e.User.Name} greets {e.GetArg("GreetedPerson")}");
                });
                cgb.CreateCommand("bye")
                .Alias(new string[] { "bb", "gb" })
                .Description("Greets a person.")
                .Parameter("GreetedPerson", ParameterType.Required)
                .Do(async e =>
                {
                    await e.Channel.SendMessage($"{e.User.Name} says goodbye to {e.GetArg("GreetedPerson")}");
                });
            });
        }
예제 #18
0
        public MyBot()
        {
            discord = new DiscordClient(x =>
            {
                x.LogLevel   = Discord.LogSeverity.Info;
                x.LogHandler = Log;
            });

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

            var commands = discord.GetService <CommandService>();

            commands.CreateCommand("type")
            .Do(async(e) =>
            {
                await e.Channel.SendIsTyping();
                // await e.Channel.DeleteMessages();
            });

            commands.CreateCommand("poop")
            .Do(async(e) =>
            {
                await e.Channel.SendMessage("POOP");
            });

            commands.CreateCommand("del")
            .Do(async(e) =>
            {
                Message[] messagestoDelete;
                messagestoDelete = await e.Channel.DownloadMessages(2);
                await e.Channel.DeleteMessages(messagestoDelete);
            });

            commands.CreateCommand("triggered")
            .Do(async(e) =>
            {
                await e.Channel.SendIsTyping();
                await e.Channel.SendFile("gif/trig.webp");
            });

            commands.CreateCommand("eg")
            .Do(async(e) =>
            {
                await e.Channel.SendIsTyping();
                await e.Channel.SendFile("gif/bear.png");
            });

            commands.CreateCommand("stocks")
            .Do(async(e) =>
            {
                //Create the quote service
                var quote_service = new QuoteService();

                //Get a quote

                var quotes = quote_service.Quote("COST", "").Return(QuoteReturnParameter.Symbol,
                                                                    QuoteReturnParameter.Name,
                                                                    QuoteReturnParameter.LatestTradePrice,
                                                                    QuoteReturnParameter.ChangeAsPercent,
                                                                    QuoteReturnParameter.LatestTradeTime);
                //Get info from the quotes
                foreach (var quote in quotes)
                {
                    //Console.WriteLine("{0} - {1} - {2} - {3}", quote.Symbol, quote.Name, quote.LatestTradePrice, quote.LatestTradeTime);
                    await e.Channel.SendMessage(quote.Name);
                    await e.Channel.SendMessage(quote.ChangeAsPercent);
                }
            });
            //Audio Portion//
            discord.UsingAudio(x =>
            {
                x.Mode = AudioMode.Outgoing;
            });

            commands.CreateCommand("joinc")
            .Do(async(e) =>
            {
                var voiceChannel = discord.FindServers("C++").FirstOrDefault().VoiceChannels.FirstOrDefault(); // Finds the first VoiceChannel on the server 'Music Bot Server'

                var _vClient = await discord.GetService <AudioService>()                                       // We use GetService to find the AudioService that we installed earlier. In previous versions, this was equivelent to _client.Audio()
                               .Join(voiceChannel);                                                            // Join the Voice Channel, and return the IAudioClient.
            });
            commands.CreateCommand("joine")
            .Do(async(e) =>
            {
                var voiceChannel = discord.FindServers("The Great Eagle Bear").FirstOrDefault().VoiceChannels.FirstOrDefault(); // Finds the first VoiceChannel on the server 'Music Bot Server'

                var _vClient = await discord.GetService <AudioService>()                                                        // We use GetService to find the AudioService that we installed earlier. In previous versions, this was equivelent to _client.Audio()
                               .Join(voiceChannel);                                                                             // Join the Voice Channel, and return the IAudioClient.
            });
            commands.CreateCommand("join")
            .Do(async(e) =>
            {
                Channel voiceChan = e.User.VoiceChannel;
                // await voiceChan.JoinAudio();
                var _vClient = await discord.GetService <AudioService>() // We use GetService to find the AudioService that we installed earlier. In previous versions, this was equivelent to _client.Audio()
                               .Join(voiceChan);                         // Join the Voice Channel, and return the IAudioClient.
            });

            commands.CreateCommand("leave")
            .Do(async(e) =>
            {
                Channel voiceChan = e.User.VoiceChannel;
                await voiceChan.LeaveAudio();
            });
            commands.CreateCommand("kys")
            .Do(async(e) =>
            {
                await discord.Disconnect();
            });
            /////Audio Portion///

            //GREETING
            discord.GetService <CommandService>().CreateCommand("greet") //create command greet
            .Alias(new string[] { "gr", "hi" })                          //add 2 aliases, so it can be run with ~gr and ~hi
            .Description("Greets a person.")                             //add description, it will be shown when ~help is used
            .Parameter("GreetedPerson", ParameterType.Required)          //as an argument, we have a person we want to greet
            .Do(async e =>
            {
                await e.Channel.SendMessage($"{e.User.Name} greets {e.GetArg("GreetedPerson")}");
                //sends a message to channel with the given text
            });
            //GREETING

            //Stocks///////////////////////////////////////////
            discord.GetService <CommandService>().CreateCommand("price") //create command greet
            .Alias(new string[] { "p", "quote" })                        //add 2 aliases, so it can be run with ~gr and ~hi
            .Description("Shows stock price.")                           //add description, it will be shown when ~help is used
            .Parameter("TickerSymbol", ParameterType.Required)           //as an argument, we have a person we want to greet
            .Do(async e =>
            {
                //Create the quote service
                var quote_service = new QuoteService();
                //Get a quote
                var quotes = quote_service.Quote($"{e.GetArg("TickerSymbol")}", "").Return(QuoteReturnParameter.Symbol,
                                                                                           QuoteReturnParameter.Name,
                                                                                           QuoteReturnParameter.LatestTradePrice,
                                                                                           QuoteReturnParameter.LatestTradeTime);

                //Get info from the quotes

                foreach (var quote in quotes)

                {
                    //Console.WriteLine("{0} - {1} - {2} - {3}", quote.Symbol, quote.Name, quote.LatestTradePrice, quote.LatestTradeTime);
                    await e.Channel.SendMessage(quote.Name);
                    await e.Channel.SendMessage("$" + quote.LatestTradePrice);
                }
                //await e.Channel.SendMessage($"{e.User.Name} greets {e.GetArg("GreetedPerson")}");
                //sends a message to channel with the given text
            })

            ;
            //STOCKS^/////////////////////////////////////

            //FLIP//
            commands.CreateCommand("flipcoin")
            .Do(async(e) =>
            {
                Random random    = new Random();
                int randomNumber = random.Next(1, 3);
                if (randomNumber == 1)
                {
                    await e.Channel.SendMessage("HEADS");
                }
                else if (randomNumber == 2)
                {
                    await e.Channel.SendMessage("TAILS");
                }
            });
            commands.CreateCommand("flipdie")
            .Do(async(e) =>
            {
                Random random    = new Random();
                int randomNumber = random.Next(1, 7);
                await e.Channel.SendMessage("" + randomNumber);
            });


            //CONNECT BOT
            discord.ExecuteAndWait(async() =>
            {
                await discord.Connect("MzM1MjM1NjU2NjAxMDQyOTQ1.DEnZhw.ANvKVSPmrLfEaEwdzhmjdTbVdtE", TokenType.Bot);
            });
        }
예제 #19
0
파일: MyBot.cs 프로젝트: smallbomb/CGSS_BOT
        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()));
            });
        }
예제 #20
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);
            });
        }
예제 #21
0
        private void Start(string[] args)
        {
#if !DNXCORE50
            Console.Title = $"{AppName} (Discord.Net v{DiscordConfig.LibVersion})";
#endif

            GlobalSettings.Load();

            _client = new DiscordClient(x =>
            {
                x.AppName               = AppName;
                x.AppUrl                = AppUrl;
                x.MessageCacheSize      = 0;
                x.UsePermissionsCache   = false;
                x.EnablePreUpdateEvents = true;
                x.LogLevel              = LogSeverity.Info;
                x.LogHandler            = OnLogMessage;
            })

                      .UsingCommands(x =>
            {
                x.PrefixChar         = '!';
                x.AllowMentionPrefix = false;
                x.HelpMode           = HelpMode.Public;
                x.ExecuteHandler     = OnCommandExecuted;

                x.ErrorHandler = OnCommandError;
            })

                      .UsingModules()
                      .UsingAudio(x =>
            {
                x.Mode = AudioMode.Outgoing;
                x.EnableMultiserver = true;
                x.EnableEncryption  = true;
                x.Bitrate           = AudioServiceConfig.MaxBitrate;
                x.BufferLength      = 10000;
            })
                      .UsingPermissionLevels(PermissionResolver)

                      .AddService <SettingsService>()
                      .AddService <HttpService>()

                      .AddModule <AdminModule>("Admin", ModuleFilter.ServerWhitelist)
                      .AddModule <ColorsModule>("Colors", ModuleFilter.ServerWhitelist)
                      //.AddModule<FeedModule>("Feeds", ModuleFilter.ServerWhitelist)
                      //.AddModule<GithubModule>("Repos", ModuleFilter.ServerWhitelist)
                      .AddModule <ModulesModule>("Modules", ModuleFilter.None)
                      .AddModule <PublicModule>("Public", ModuleFilter.None)
                      .AddModule <TwitchModule>("Twitch", ModuleFilter.None)
                      .AddModule <StatusModule>("Status", ModuleFilter.ServerWhitelist)
                      .AddModule <Music>("Music", ModuleFilter.ServerWhitelist)
                      .AddModule <DiscordBot.Modules.Sql.sql>("sql", ModuleFilter.None);

            PublicModule.loadgods();

            //.AddModule(new ExecuteModule(env, exporter), "Execute", ModuleFilter.ServerWhitelist);

#if PRIVATE
            PrivateModules.Install(_client);
#endif

            /* IAudioClient test = new IAudioClient();
             * test.*/
            //Convert this method to an async function and connect to the server
            //DiscordClient will automatically reconnect once we've established a connection, until then we loop on our end
            //Note: ExecuteAndWait is only needed for Console projects as Main can't be declared as async. UI/Web applications should *not* use this function.

            _client.UserJoined += async(s, e) =>
            {
                DiscordBot.Modules.Sql.sql sqll = new Modules.Sql.sql();
                string message = sqll.getsinglevalue("servers", "server = " + e.Server.Id, "welcome");
                if (message != "" && message != null && message.Length > 0)
                {
                    Channel pm = await _client.CreatePrivateChannel(e.User.Id);

                    await pm.SendMessage(message);
                }
            };

            _client.ExecuteAndWait(async() =>
            {
                while (true)
                {
                    try
                    {
                        await _client.Connect(GlobalSettings.Discord.Email, GlobalSettings.Discord.Password);
                        _client.SetGame("O Bot");
                        break;
                    }
                    catch (Exception ex)
                    {
                        _client.Log.Error($"Login Failed", ex);
                        await Task.Delay(_client.Config.FailedReconnectDelay);
                    }
                }
            });
        }