Exemple #1
0
        public async Task BoostFeetPics(CommandContext ctx)
        {
            var context = new DiscordContext();

            var minTime = DateTime.Now - TimeSpan.FromHours(6);
            var boosts  = context.Boost.Where(b => b.Date > minTime && (b.Channel == null || b.Channel == Convert.ToInt64(ctx.Channel.Id)));

            if (await boosts.CountAsync() > 4)
            {
                await ctx.RespondAsync($"You have to wait before boosting again. Next one is available in {(TimeSpan.FromHours(6) - (DateTime.Now - boosts.Last().Date)).TotalMinutes} minutes.");

                return;
            }

            var sabrinaSettings = await context.SabrinaSettings.FindAsync(Convert.ToInt64(ctx.Guild.Id));

            if (sabrinaSettings.FeetChannel == null)
            {
                sabrinaSettings.FeetChannel = Convert.ToInt64(ctx.Channel.Id);
            }

            var channel = await ctx.Client.GetChannelAsync(Convert.ToUInt64(sabrinaSettings.FeetChannel));

            if (sabrinaSettings.FeetChannel.Value != Convert.ToInt64(ctx.Channel.Id))
            {
                await ctx.RespondAsync($"You cannot issue this command from this Channel. Please use {channel.Mention}");

                return;
            }

            var picsToPost = Helpers.RandomGenerator.RandomInt(2, 5);

            for (int i = 0; i < picsToPost; i++)
            {
                await TumblrBot.PostRandom(ctx.Client, context, new DiscordChannel[] { channel });
            }

            context.Boost.Add(new Boost()
            {
                Amount = picsToPost,
                Date   = DateTime.Now
            });
            await context.SaveChangesAsync();
        }
Exemple #2
0
        public async Task MainAsync()
        {
            this.SetConfig();
            this.SetCommands();
            this.CreateFolders();

            await this.client.ConnectAsync();

            this.client.Ready                += this.OnReadyAsync;
            this.client.MessageCreated       += this.ClientMessageCreated;
            this.client.MessageReactionAdded += this.ClientMessageReactionAdded;
            this.client.GuildMemberUpdated   += this.ClientGuildMemberUpdated;

            this.conn = new SqlConnection(Config.DatabaseConnectionString);
            await this.conn.OpenAsync();

            await this.client.UpdateStatusAsync(new DiscordGame("Feetsies"), UserStatus.Online);

            // TODO: Looks weird, cause unused.
            SankakuBot sankakuBot = new SankakuBot(this.client);
            PornhubBot pornhubBot = new PornhubBot(this.client);
            HelpBot    helpBot    = new HelpBot(this.client);

            this.tmblrBot = new TumblrBot(this.client);

            var exit = false;

            while (!exit)
            {
                string command = Console.ReadLine();
                switch (command)
                {
                case "stop":
                case "exit":
                case "x":
                    PornhubBot.Exit = true;
                    exit            = true;
                    break;
                }
            }

            await this.client.DisconnectAsync();
        }