Exemple #1
0
        public CommandHandler(
            DiscordSocketClient discord,
            CommandService commands,
            Configuration config,
            IServiceProvider provider,
            FloraDebugLogger logger,
            Reactions reactions,
            FloraRandom random)
        {
            _discord       = discord;
            _commands      = commands;
            _provider      = provider;
            _config        = config;
            _logger        = logger;
            _reactions     = reactions;
            _random        = random;
            _ownerChannels = new List <AsyncLazy <IDMChannel> >();

            //Set up DM channels for owners
            foreach (ulong ownerID in _config.Owners)
            {
                _ownerChannels.Add(new AsyncLazy <IDMChannel>(async() => await _discord.GetUser(ownerID).GetOrCreateDMChannelAsync()));
            }

            _discord.MessageReceived += OnMessageReceivedAsync;
        }
Exemple #2
0
 public Administration(FloraRandom random, FloraDebugLogger logger, DiscordSocketClient client, Configuration config, BotGameHandler botGames)
 {
     _random   = random;
     _logger   = logger;
     _client   = client;
     _botGames = botGames;
     _config   = config;
 }
        public InfiniteDie(FloraRandom random, FloraDebugLogger logger, Cooldowns cooldowns)
        {
            _random    = random;
            _logger    = logger;
            _cooldowns = cooldowns;

            _cooldowns.GetOrSetupCommandCooldowns("InfiniteDieCreate");
        }
Exemple #4
0
        public Misc(FloraRandom random, FloraDebugLogger logger, Configuration config, NameLocker nameLocker)
        {
            _client = new HttpClient();
            _random = random;
            _logger = logger;
            _config = config;

            _nameLocker = nameLocker;
        }
Exemple #5
0
        public Games(FloraRandom random, FloraDebugLogger logger, BotGameHandler botGames, WoodcuttingLocker woodcuttingLocker, Configuration config, HeartLocker heartLocker)
        {
            _random   = random;
            _logger   = logger;
            _botGames = botGames;
            _config   = config;

            _woodcuttingLocker = woodcuttingLocker;
            _healthLocker      = heartLocker;
        }
Exemple #6
0
        public async Task AsyncMain()
        {
            _config          = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(@"data/config.json"));
            _config.Shutdown = false;
            _random          = new FloraRandom();

            _reactions = new Reactions(_random);
            await _reactions.LoadReactionsFromDatabase();

            _botGames = new BotGameHandler(_random, _client, _logger);
            await _botGames.LoadBotGamesFromDB();

            //Services
            InitServices();

            var provider = _map.BuildServiceProvider();

            //Command Setup
            await InitCommands(provider);

            _commands.Log += Log;

            await _client.LoginAsync(TokenType.Bot, _config.Token);

            await _client.StartAsync();

            provider.GetRequiredService <CommandHandler>();
            //provider.GetRequiredService<StartupHandler>();
            provider.GetRequiredService <ReactionHandler>();
            provider.GetRequiredService <ImageRateLimitHandler>();
            provider.GetRequiredService <ReactionHandler>();

            _logger.Log("Updating User List", "Startup");

            foreach (SocketGuild guild in _client.Guilds)
            {
                await guild.DownloadUsersAsync();
            }

            if (_config.RotatingGames)
            {
                _logger.Log("Starting game rotation", "RotatingGames");
                WorkingTask();
            }

            //Block task until program is closed
            await Task.Delay(-1);
        }
        public async Task EndGameInChannel(IGuild guild, IMessageChannel ChannelID, FloraRandom _random)
        {
            RNGGame game = StopRNGG(ChannelID.Id);

            if (game != null)
            {
                int roll = _random.Next(game.MinGuess, game.MaxGuess + 1);
                if (game.Guesses.Select(x => x.GuessIndex == roll).FirstOrDefault())
                {
                    var        winnerID = game.Guesses.First(x => x.GuessIndex == roll);
                    IGuildUser user     = await guild.GetUserAsync(winnerID.UserID);

                    await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithOkColour()
                                                    .AddField(new EmbedFieldBuilder().WithName("🎲 Roll").WithValue(roll))
                                                    .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue(user.Username)).Build());
                }
                else
                {
                    await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithErrorColour()
                                                    .AddField(new EmbedFieldBuilder().WithName("🎲 Roll").WithValue(roll))
                                                    .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue("Nobody. That's sad.")).Build());
                }
            }
        }
 public CustomRoles(FloraRandom random, FloraDebugLogger logger)
 {
     _random = random;
     _logger = logger;
 }
Exemple #9
0
 public NoLifes(FloraRandom random)
 {
     _random = random;
 }
Exemple #10
0
 public DnD(FloraRandom random, FloraDebugLogger logger, DiscordSocketClient client)
 {
     _random = random;
     _logger = logger;
     _client = client;
 }
Exemple #11
0
 public Money(FloraRandom random, FloraDebugLogger logger, Configuration config)
 {
     _random = random;
     _logger = logger;
     _config = config;
 }
Exemple #12
0
 public CustomReactions(FloraRandom random, FloraDebugLogger logger, Reactions reactions)
 {
     _random    = random;
     _logger    = logger;
     _reactions = reactions;
 }
Exemple #13
0
 public Cyphers(FloraRandom random, FloraDebugLogger logger)
 {
     _random = random;
     _logger = logger;
 }