Exemple #1
0
        // TODO: move to handler class
        private async Task HandleOnMessageReceivedAsync(SocketMessage socketMessage)
        {
            // ReSharper disable once UseNegatedPatternMatching
            var message = socketMessage as SocketUserMessage;

            if (message == null)
            {
                return;
            }

            var argPos = 0;
            var prefix = _options.Prefix;

            if (!message.HasStringPrefix(prefix, ref argPos) || message.Author.IsBot)
            {
                return;
            }

            if (EnvironmentsHelper.IsProduction() && socketMessage.Channel.Name != "commands-use")
            {
                return;
            }

            var context = new SocketCommandContext(_client, message);

            await _commandService.ExecuteAsync(context, argPos, _serviceProvider);
        }
        public void ShouldProductionBeFalse_WhenEnvvarIsUnknown()
        {
            TestHelper.SetEnvironmentName("abc");

            var result = EnvironmentsHelper.IsProduction();

            Assert.IsFalse(result);
        }
        public void ShouldProductionBeTrue_WhenEnvvarIsProduction()
        {
            TestHelper.SetEnvironmentName("production");

            var result = EnvironmentsHelper.IsProduction();

            Assert.IsTrue(result);
        }