Beispiel #1
0
        public async Task Start()
        {
            // Define the DiscordSocketClient with a DiscordSocketConfig
            client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                LogLevel = LogSeverity.Info
            });

            var token = "token here";

            // Login and connect to Discord.
            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            var map = new DependencyMap();

            map.Add(client);

            handler = new CommandHandler();
            await handler.Install(map);

            // add logger
            client.Log += Log;

            // Log the invite URL on client ready
            client.Ready += Client_Ready;

            // Block this program until it is closed.
            await Task.Delay(-1);
        }
Beispiel #2
0
        public async Task Start()
        {
            Console.WriteLine("start");
            // Define the DiscordSocketClient
            client = new DiscordSocketClient();

            var token = File.ReadAllText("Token.txt");

            client.Connected += async() =>
            {
                await client.SetGameAsync("?help");
            };

            // Login and connect to Discord.
            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            var map = new DependencyMap();

            map.Add(client);

            handler = new CommandHandler();
            await handler.Install(map);

            Console.WriteLine("Connected");
            // Block this program until it is closed.
            await Task.Delay(-1);
        }
        public async Task Start()
        {
            client = new DiscordSocketClient();

            await client.LoginAsync(TokenType.Bot, "TOKEN HERE");

            await client.ConnectAsync();

            var map = new DependencyMap();

            map.Add(client);

            handler = new CommandHandler();
            await handler.Install(map);

            await Task.Delay(-1);
        }
Beispiel #4
0
        public async Task Start()
        {
            // Define the DiscordSocketClient
            client = new DiscordSocketClient();

            var token = "token here";

            // Login and connect to Discord.
            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            var map = new DependencyMap();

            map.Add(client);

            handler = new CommandHandler();
            await handler.Install(map);

            // Block this program until it is closed.
            await Task.Delay(-1);
        }
        private ulong usrlogcID = 287990510428225537; //287990510428225537 306909741622362112


        public async Task Start()
        {
            // Define the DiscordSocketClient
            client = new DiscordSocketClient();

            var token = "Mshitlol"

                        client.Log += async(message) =>
            {
                await Log(message);
            };

            client.JoinedGuild += async(m) =>
            {
                IGuild       usr  = client.GetGuild(usrID);
                ITextChannel usrc = await usr.GetTextChannelAsync(usrlogcID);

                await usrc.SendMessageAsync($":slight_smile: I have joined `{m.Name}`(`{m.Id}`), I am now in {client.Guilds.Count} servers!");

                await m.DefaultChannel.SendMessageAsync("Hi I am **Sandwich Delivery Bot**.Thank you for choosing our bot! To order a Sandwich, type `;order extra large blt`. For the list of commands, we have `;help`. If you wish to contact us, please use `; server`. \r\n **Please understand that when you order, you will recieve what you ordered from a *****real*****person. They have feelings.**");

                if (!m.CurrentUser.GuildPermissions.CreateInstantInvite)
                {
                    await m.DefaultChannel.SendMessageAsync(":warning: The bot cannot create instant invites! Please give the bot permission or else it will not work! :warning: ");
                }
            };

            client.LeftGuild += async(m) =>
            {
                IGuild       usr  = client.GetGuild(usrID);
                ITextChannel usrc = await usr.GetTextChannelAsync(usrlogcID);

                await usrc.SendMessageAsync($":slight_frown: I have left `{m.Name}`(`{m.Id}`), I am now in {client.Guilds.Count} servers...");
            };

            client.MessageReceived += async(m) =>
            {
                if (m.Author.IsBot)
                {
                    return;
                }
                if (m.Channel.Id == client.CurrentUser.Id)
                {
                    return;
                }
                if (m.MentionedUsers.Any(u => u.Id == client.CurrentUser.Id))
                {
                    if (m.Content.Contains("help"))
                    {
                        await m.Channel.SendMessageAsync("Type `;help`. `;server` if you have any problems.");
                    }
                }
                var rnd = new Random();
                var r   = rnd.Next(1, 25);
                if (r == 2)
                {
                    var totalChannels = 0;
                    var totalUsers    = 0;
                    foreach (var obj in client.Guilds)
                    {
                        totalChannels = totalChannels + obj.Channels.Count;
                        totalUsers    = totalUsers + obj.Users.Count;
                    }
                    await client.SetGameAsync($"In {totalChannels} channels with a total of {totalUsers} users! | Type ;motd for help!");
                }
                if (r == 6)
                {
                    await client.SetGameAsync($"In {client.Guilds.Count()} servers! | Type ;motd for help!");
                }
            };



            ss = new SandwichService();
            ss.Load();
            foreach (var obj in ss.activeOrders)
            {
                if (obj.Value.Status == OrderStatus.ReadyToDeliver)
                {
                    ss.toBeDelivered.Add(obj.Value.Id);
                    Console.WriteLine($"Added order {obj.Value.Id} to toBeDelivered.");
                }
            }
            // Login and connect to Discord.
            var map = new DependencyMap();

            map.Add(client);
            handler = new CommandHandler();
            map.Add(ss);
            await handler.Install(map);

            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            // Block this program until it is closed.
            await Task.Delay(-1);
        }
Beispiel #6
0
        public async Task Start()
        {
            // Define the DiscordSocketClient
            client      = new DiscordSocketClient();
            client.Log += (x => {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write($"[{DateTime.Now.GetDateTimeFormats()[110]}]");
                switch ((int)x.Severity)
                {
                case 0:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;

                case 1:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;

                case 2:
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    break;

                case 3:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;

                case 4:
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    break;

                case 5:
                    Console.ForegroundColor = ConsoleColor.DarkMagenta;
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                } //sets color according to severity
                Console.WriteLine(x.Message);
                return(Task.CompletedTask);
            });
            var token = File.ReadAllText("token.txt");

            // Login and connect to Discord.
            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            var map = new DependencyMap();

            map.Add(client);

            handler = new CommandHandler();
            await handler.Install(map);

            client.Ready += Client_Ready;
            Task Client_Ready()
            {
                client.SetStatusAsync(UserStatus.Online);
                client.SetGameAsync("Type >help!");
                return(Task.CompletedTask);
            }

            // Block this program until it is closed.
            client.LeftGuild += x =>
            {
                int count = int.Parse(File.ReadAllText("servercount.dat"));
                count--;
                File.WriteAllText("servercount.dat", count.ToString());
                return(Task.CompletedTask);
            };
            client.JoinedGuild += (async x => {
                await x.DefaultChannel.SendMessageAsync($"Hello I am {client.CurrentUser.Username} 😄.\rI am currently in early development so please report any problems to @Ariss#4202.\rType >help to get started!");
                int count = int.Parse(File.ReadAllText("servercount.dat"));
                count++;
                File.WriteAllText("servercount.dat", count.ToString());
                var g = x as IGuild;
                var channels = await g.GetChannelsAsync();
                GuildPermissions perms = GuildPermissions.None;
                perms = g.EveryoneRole.Permissions.Modify(sendMessages: false);
                Dictionary <string, ulong> roledict = g.Roles.ToDictionary(a => { return(a.Name); }, y => { return(y.Id); });
                IRole muteRole = null;
                if (roledict.ContainsKey("Muted") == false)
                {
                    muteRole = await g.CreateRoleAsync("Muted", perms, new Color(50, 50, 50), true);
                }
                else
                {
                    roledict.TryGetValue("Muted", out ulong id);
                    muteRole = g.GetRole(id);
                }
                OverwritePermissions per = new OverwritePermissions();
                per = OverwritePermissions.InheritAll.Modify(sendMessages: PermValue.Deny);
                foreach (IGuildChannel chan in channels)
                {
                    await chan.AddPermissionOverwriteAsync(muteRole, per);
                }
            });
            await GetInput();

            await Task.Delay(-1);
        }