Пример #1
0
        private async Task HandleCommandAsync(SocketMessage messageParam)
        {
            // Don't process the command if it was a system message
            var message = messageParam as SocketUserMessage;

            Console.WriteLine(message.Content);
            if (message == null)
            {
                return;
            }

            // Create a number to track where the prefix ends and the command begins
            int argPos = 0;

            //load mod commands for bot use
            Mod_Actions actions = new Mod_Actions();

            //detect for banned words
            if (AutoMod.WordFilter(message.Content, out string reason))
            {
                string link = "https://discordapp.com/channels/597798914606759959/" + message.Channel.Id + "/" + message.Id;
                await message.Channel.SendMessageAsync(":exclamation: :eyes: :exclamation: " + message.Author.Mention + ", you used the " + reason + " This will be logged and may be used against you. " + link);

                await actions.LogInfraction(message.Author, _client.CurrentUser, message.Channel, reason);

                return;
            }

            // Determine if the message is a command based on the prefix and make sure no bots trigger commands
            if (!(message.HasCharPrefix('!', ref argPos) ||
                  message.HasMentionPrefix(_client.CurrentUser, ref argPos)) ||
                message.Author.IsBot)
            {
                return;
            }

            Console.WriteLine(message.Content);
            // Create a WebSocket-based command context based on the message
            var context = new SocketCommandContext(_client, message);

            // Execute the command with the command context we just
            // created, along with the service provider for precondition checks.
            await _commands.ExecuteAsync(
                context : context,
                argPos : argPos,
                services : null);
        }